diff --git a/PlayWall/.classpath b/PlayWall/.classpath index 0ede5a8607f5719c73b0d0fa43b800cacfe55769..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" 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 6e553fe7b55f64165bef092e56959af31f7551a3..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,10 +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.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 @@ -31,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 @@ -62,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. @@ -96,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 @@ -110,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 @@ -128,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. ({}) @@ -142,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. @@ -155,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 @@ -173,7 +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. \nDieses kann aus Buchstaben, Ziffern und/oder den F-Tasten bestehen. # UI - Window - PadSettings UI.Window.PadSettings.General.Title=Allgemein @@ -202,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 @@ -215,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 @@ -235,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 1ad02a367c7a457e081958a4693bd4964f761953..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,10 +1,12 @@ #Sprachdatei f�r die Benutzeroberfl�che +#Kommentare befinden sich immer -->�BER<-- dem jeweiligen Eintrag main.menu.file=Datei main.menu.option=Optionen main.menu.view=Ansicht main.menu.info=Info main.menu.extension=Erweitert +main.menu.help=Hilfe main.menuitem.new=Neues Projekt... main.menuitem.project=Projekte verwalten... @@ -16,11 +18,16 @@ main.menuitem.onTop=Fenster im Vordergrund main.menuitem.plugins=Erweiterungen... main.menuitem.dnd=Bearbeitungsmodus main.menuitem.errors=Fehlerbericht anzeigen... -main.menuitem.settings=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... main.menuitem.fullScreen=Vollbild +main.menuitem.layout=Layout +main.menuitem.close=Touch Modus schlie�en +main.menuitem.searchPad=Kachel suchen... main.label.live=Live @@ -28,7 +35,6 @@ settings.gen.label.view=Ansicht: settings.gen.label.pages=Anzahl der Seiten: settings.gen.label.columns=Anzahl der Spalten: settings.gen.label.rows=Anzahl der Reihen: -settings.gen.label.additional=Erweitert: settings.gen.label.liveMode=Live Modus: settings.gen.checkbox.liveMode=Aktivieren settings.gen.label.liveMode.settings=Einstellungen �ndern: @@ -52,6 +58,8 @@ settings.midi.label.device=Midi-Ger settings.layout.label.type=Layout Type: +settings.player.label.modus=Wiedergabemodus: +settings.player.checkbox.modus=Mehrere Player gleichzeitig wiedergeben settings.player.label.warning=Warnhinweise: settings.player.label.fade=Ein-/Ausblenden: settings.player.label.fadeIn=Einblenden (in s): @@ -69,10 +77,23 @@ 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=Tastenkombination: +settings.keys.button.change=�ndern +settings.keys.button.delete=L�schen +settings.keys.table.name=Name +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 @@ -98,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: @@ -120,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: @@ -152,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 @@ -169,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: @@ -195,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: @@ -204,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/modern_style.css b/PlayWall/assets/de/tobias/playpad/assets/modern_style.css index e6696ef97cc54d85301cd95b4ee53c8d2789b095..84ae1898d566a5f64fa01c995e0619c2c561284f 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/modern_style.css +++ b/PlayWall/assets/de/tobias/playpad/assets/modern_style.css @@ -146,4 +146,4 @@ .progress-indicator .percentage { -fx-fill: white; -} \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..7c3f13e0e822b0adf8dd956e163a68d8e29eedab --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/style/touch.css @@ -0,0 +1,25 @@ +.menu .label { + -fx-font-size: 25px; + -fx-padding: 10px; +} + +.label { + -fx-font-size: 20px; +} + +.button { + -fx-font-size : 20px; +} + +.slider .track { + -fx-pref-height: 15; +} + +.slider:vertical .track { + -fx-pref-width: 20; +} + +.slider .thumb { + -fx-pref-height: 30; + -fx-pref-width: 30; +} \ No newline at end of file diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/actions/cartActions.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/actions/cartActions.fxml index f51a447b46c39cce3eed03f403278af7ff0e9b40..58435207ea126084a7a545740393ec06917a404c 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/actions/cartActions.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/actions/cartActions.fxml @@ -5,10 +5,8 @@ <?import java.lang.*?> <?import javafx.scene.layout.*?> - <VBox fx:id="buttonVbox" spacing="7.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <children> - <HBox fx:id="pageHbox" minHeight="20.0" spacing="7.0" VBox.vgrow="NEVER" /> <GridPane fx:id="gridPane" alignment="CENTER" hgap="7.0" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" vgap="7.0" VBox.vgrow="NEVER"> <columnConstraints> <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> 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 new file mode 100644 index 0000000000000000000000000000000000000000..dd7c7d2aa525e7b2093debec88e177d3f3cdc92f --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml @@ -0,0 +1,125 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import java.lang.*?> +<?import javafx.scene.control.*?> +<?import javafx.scene.layout.*?> +<?import javafx.scene.input.*?> +<?import javafx.scene.text.*?> + +<VBox maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <children> +<MenuBar fx:id="menuBar" prefHeight="29.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <menus> + <Menu mnemonicParsing="false" text="%main.menu.file"> + <items> + <MenuItem fx:id="newProjectMenuItem" 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 fx:id="openProjectMenuItem" 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="saveProjectMenuItem" 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 fx:id="printProjectMenuItem" 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 fx:id="pluginMenu" mnemonicParsing="false" onAction="#pluginMenuItemHandler" text="%main.menuitem.plugins" /> + <SeparatorMenuItem mnemonicParsing="false" /> + <MenuItem fx:id="projectSettingsMenuItem" mnemonicParsing="false" onAction="#projectSettingsHandler" text="%main.menuitem.projectSettings" /> + <MenuItem fx:id="profileSettingsMenuItem" mnemonicParsing="false" onAction="#profileSettingsHandler" text="%main.menuitem.profileSettings"> + <accelerator> + <KeyCodeCombination alt="UP" code="COMMA" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> + </accelerator> + </MenuItem> + <MenuItem fx:id="globalSettingsMenuItem" mnemonicParsing="false" onAction="#globalSettingsHandler" text="%main.menuitem.globalSettings"> + <accelerator> + <KeyCodeCombination alt="UP" code="COMMA" control="UP" meta="UP" shift="DOWN" shortcut="DOWN" /> + </accelerator> + </MenuItem> + </items> + </Menu> + <Menu fx:id="layoutMenu" 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> + <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" /> + <Menu fx:id="infoMenu" 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> + <Menu fx:id="helpMenu" mnemonicParsing="false" text="%main.menu.help" /> + </menus> +</MenuBar> +<ToolBar fx:id="toolbar" VBox.vgrow="ALWAYS" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <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" maxWidth="1.7976931348623157E308" spacing="14.0" HBox.hgrow="ALWAYS" /> + <HBox fx:id="iconHbox" alignment="CENTER" spacing="14.0"> + <children> + <Label fx:id="liveLabel" text="%main.label.live" textFill="RED"> + <font> + <Font size="26.0" /> + </font> + </Label> + </children></HBox> + <HBox fx:id="searchFieldHbox" /> + <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> + </children> +</VBox> 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/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/mainToolbarView.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml similarity index 52% rename from PlayWall/assets/de/tobias/playpad/assets/view/main/mainToolbarView.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml index 38c491f3c86f75ba41c1599a33c1f35317b49427..4064a2aea4283892bda5ab3357fed8f40564699f 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/mainToolbarView.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml @@ -3,14 +3,24 @@ <?import java.lang.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> +<?import javafx.scene.input.*?> <?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"> +<HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <children> +<ToolBar fx:id="toolbar" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS" VBox.vgrow="ALWAYS"> <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 fx:id="pageHBox" alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" spacing="14.0" HBox.hgrow="ALWAYS" /> + <HBox fx:id="iconHbox" alignment="CENTER" spacing="14.0"> + <children> + <Label fx:id="liveLabel" text="%main.label.live" textFill="RED"> + <font> + <Font size="26.0" /> + </font> + </Label> + </children></HBox> <HBox alignment="CENTER" spacing="7.0" HBox.hgrow="NEVER"> <children> <Label fx:id="volumeDownLabel"> @@ -18,15 +28,18 @@ <Font size="24.0" /> </font> </Label> - <Slider fx:id="volumeSlider" focusTraversable="false" max="1.0" /> + <Slider fx:id="volumeSlider" focusTraversable="false" max="1.0" prefWidth="200.0" /> <Label fx:id="volumeUpLabel"> <font> <Font size="24.0" /> </font> </Label> + <Button fx:id="closeButton" focusTraversable="false" mnemonicParsing="false" onAction="#closeMenuItemHandler" text="X" /> </children> </HBox> </children> </HBox> </items> </ToolBar> + </children> +</HBox> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/generalTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/generalTab.fxml deleted file mode 100644 index c37bccfea43073122df709a2f0ec317b880e795f..0000000000000000000000000000000000000000 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/generalTab.fxml +++ /dev/null @@ -1,115 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import javafx.geometry.*?> -<?import java.lang.*?> -<?import javafx.scene.control.*?> -<?import javafx.scene.layout.*?> - -<ScrollPane fitToWidth="true" prefHeight="775.0" prefWidth="590.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> - <content> - <VBox spacing="14.0"> - <children> - <Label text="%settings.gen.label.view" underline="true" /> - <HBox spacing="14.0"> - <children> - <Label alignment="BASELINE_RIGHT" layoutX="21.0" layoutY="40.0" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.pages" /> - <TextField fx:id="pageCountTextField" prefWidth="50.0" /> - </children> - </HBox> - <HBox spacing="14.0"> - <children> - <Label alignment="BASELINE_RIGHT" layoutX="20.0" layoutY="68.0" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.columns" /> - <TextField fx:id="columnTextField" prefWidth="50.0" /> - </children> - </HBox> - <HBox spacing="14.0"> - <children> - <Label alignment="BASELINE_RIGHT" layoutX="18.0" layoutY="96.0" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.rows" /> - <TextField fx:id="rowTextField" prefWidth="50.0" /> - </children> - </HBox> - <Separator prefHeight="2.0" prefWidth="600.0" /> - <Label text="%settings.gen.label.additional" underline="true" /> - <HBox spacing="14.0"> - <children> - <Label alignment="BASELINE_RIGHT" maxWidth="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.liveMode" /> - <CheckBox fx:id="liveModeCheckBox" layoutX="30.0" layoutY="269.0" mnemonicParsing="false" text="%settings.gen.checkbox.liveMode" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="269.0" /> - </children> - </HBox> - <HBox spacing="14.0"> - <children> - <Label prefWidth="150.0" text="%settings.gen.label.liveMode.pageChange" /> - <RadioButton fx:id="pageEnable" mnemonicParsing="false" prefWidth="125.0" text="%settings.gen.radio.liveMode.enable" /> - <RadioButton fx:id="pageDisable" mnemonicParsing="false" prefWidth="100.0" text="%settings.gen.radio.liveMode.disable" /> - </children> - <VBox.margin> - <Insets left="164.0" /> - </VBox.margin> - </HBox> - <HBox spacing="14.0"> - <children> - <Label prefWidth="150.0" text="%settings.gen.label.liveMode.dragPads" /> - <RadioButton fx:id="dragEnable" mnemonicParsing="false" prefWidth="125.0" text="%settings.gen.radio.liveMode.enable" /> - <RadioButton fx:id="dragDisable" mnemonicParsing="false" prefWidth="100.0" text="%settings.gen.radio.liveMode.disable" /> - </children> - <VBox.margin> - <Insets left="164.0" /> - </VBox.margin> - </HBox> - <HBox spacing="14.0"> - <VBox.margin> - <Insets left="164.0" /> - </VBox.margin> - <children> - <Label prefWidth="150.0" text="%settings.gen.label.liveMode.media" /> - <RadioButton fx:id="fileEnable" mnemonicParsing="false" prefWidth="125.0" text="%settings.gen.radio.liveMode.enable" /> - <RadioButton fx:id="fileDisable" mnemonicParsing="false" prefWidth="100.0" text="%settings.gen.radio.liveMode.disable" /> - </children> - </HBox> - <HBox spacing="14.0"> - <VBox.margin> - <Insets left="164.0" /> - </VBox.margin> - <children> - <Label prefWidth="150.0" text="%settings.gen.label.liveMode.settings" /> - <RadioButton fx:id="settingsEnable" mnemonicParsing="false" prefWidth="125.0" text="%settings.gen.radio.liveMode.enable" /> - <RadioButton fx:id="settingsDisable" mnemonicParsing="false" prefWidth="100.0" text="%settings.gen.radio.liveMode.disable" /> - </children> - </HBox> - <Label text="%settings.gen.label.liveModeInfo" wrapText="true"> - <VBox.margin> - <Insets left="164.0" /> - </VBox.margin> - </Label> - <HBox spacing="14.0"> - <children> - <Label alignment="BASELINE_RIGHT" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.cache.label" /> - <TextField fx:id="cacheTextField" promptText="C:\Users\Max\Cache" HBox.hgrow="ALWAYS" /> - <Button mnemonicParsing="false" onAction="#cacheChooseHandler" text="%settings.gen.cache.button.choose" /> - </children> - </HBox> - <HBox alignment="CENTER_LEFT" spacing="14.0"> - <children> - <Label prefWidth="150.0" /> - <Button mnemonicParsing="false" onAction="#cacheResetButtonHandler" text="%settings.gen.cache.button.reset" /> - <Label fx:id="cacheSizeLabel" text="Label" /> - </children> - </HBox> - <Label text="%settings.gen.cache.label.info" wrapText="true"> - <VBox.margin> - <Insets left="164.0" /> - </VBox.margin> - </Label> - <Separator prefWidth="200.0" /> - <Button alignment="TOP_LEFT" mnemonicParsing="false" onAction="#resetDialogs" text="%settings.gen.warning.button.reset"> - <VBox.margin> - <Insets left="164.0" /> - </VBox.margin> - </Button> - </children> - <padding> - <Insets bottom="14.0" left="14.0" right="14.0" top="14.0" /> - </padding> - </VBox> - </content> -</ScrollPane> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/global/generalTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/generalTab.fxml new file mode 100644 index 0000000000000000000000000000000000000000..15dd7abda12eeed8cdce5fdd0692277fcb6df627 --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/generalTab.fxml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import java.lang.*?> +<?import javafx.scene.control.*?> +<?import javafx.scene.layout.*?> + +<VBox prefWidth="800.0" spacing="14.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <children> + <HBox spacing="14.0"> + <children> + <Label alignment="BASELINE_RIGHT" maxWidth="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.liveMode" /> + <CheckBox fx:id="liveModeCheckBox" layoutX="30.0" layoutY="269.0" mnemonicParsing="false" text="%settings.gen.checkbox.liveMode" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="269.0" /> + </children> + </HBox> + <HBox spacing="14.0"> + <children> + <Label prefWidth="150.0" text="%settings.gen.label.liveMode.pageChange" /> + <RadioButton fx:id="pageEnable" mnemonicParsing="false" prefWidth="125.0" text="%settings.gen.radio.liveMode.enable" /> + <RadioButton fx:id="pageDisable" mnemonicParsing="false" prefWidth="100.0" text="%settings.gen.radio.liveMode.disable" /> + </children> + <VBox.margin> + <Insets left="164.0" /> + </VBox.margin> + </HBox> + <HBox spacing="14.0"> + <children> + <Label prefWidth="150.0" text="%settings.gen.label.liveMode.dragPads" /> + <RadioButton fx:id="dragEnable" mnemonicParsing="false" prefWidth="125.0" text="%settings.gen.radio.liveMode.enable" /> + <RadioButton fx:id="dragDisable" mnemonicParsing="false" prefWidth="100.0" text="%settings.gen.radio.liveMode.disable" /> + </children> + <VBox.margin> + <Insets left="164.0" /> + </VBox.margin> + </HBox> + <HBox spacing="14.0"> + <VBox.margin> + <Insets left="164.0" /> + </VBox.margin> + <children> + <Label prefWidth="150.0" text="%settings.gen.label.liveMode.media" /> + <RadioButton fx:id="fileEnable" mnemonicParsing="false" prefWidth="125.0" text="%settings.gen.radio.liveMode.enable" /> + <RadioButton fx:id="fileDisable" mnemonicParsing="false" prefWidth="100.0" text="%settings.gen.radio.liveMode.disable" /> + </children> + </HBox> + <HBox spacing="14.0"> + <VBox.margin> + <Insets left="164.0" /> + </VBox.margin> + <children> + <Label prefWidth="150.0" text="%settings.gen.label.liveMode.settings" /> + <RadioButton fx:id="settingsEnable" mnemonicParsing="false" prefWidth="125.0" text="%settings.gen.radio.liveMode.enable" /> + <RadioButton fx:id="settingsDisable" mnemonicParsing="false" prefWidth="100.0" text="%settings.gen.radio.liveMode.disable" /> + </children> + </HBox> + <Label text="%settings.gen.label.liveModeInfo" wrapText="true"> + <VBox.margin> + <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" /> + <TextField fx:id="cacheTextField" promptText="C:\Users\Max\Cache" HBox.hgrow="ALWAYS" /> + <Button mnemonicParsing="false" onAction="#cacheChooseHandler" text="%settings.gen.cache.button.choose" /> + </children> + </HBox> + <HBox alignment="CENTER_LEFT" spacing="14.0"> + <children> + <Label prefWidth="150.0" /> + <Button mnemonicParsing="false" onAction="#cacheResetButtonHandler" text="%settings.gen.cache.button.reset" /> + <Label fx:id="cacheSizeLabel" text="Label" /> + </children> + </HBox> + <Label text="%settings.gen.cache.label.info" wrapText="true"> + <VBox.margin> + <Insets left="164.0" /> + </VBox.margin> + </Label> + <Separator prefWidth="200.0" /> + <Button alignment="TOP_LEFT" mnemonicParsing="false" onAction="#resetDialogs" text="%settings.gen.warning.button.reset"> + <VBox.margin> + <Insets left="164.0" /> + </VBox.margin> + </Button> + </children> + <padding> + <Insets bottom="14.0" left="14.0" right="14.0" top="14.0" /> + </padding> +</VBox> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/global/globalSettingsView.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/globalSettingsView.fxml new file mode 100644 index 0000000000000000000000000000000000000000..23efae52a75f75d6b931db277299917bba3eea67 --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/globalSettingsView.fxml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import javafx.scene.control.*?> +<?import java.lang.*?> +<?import javafx.scene.layout.*?> + +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="592.0" prefWidth="645.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <children> + <TabPane fx:id="tabPane" prefHeight="348.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="52.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> + <Button fx:id="finishButton" layoutX="508.0" layoutY="360.0" mnemonicParsing="false" onAction="#finishButtonHandler" text="%settings.button.finish" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="14.0" /> + </children> +</AnchorPane> 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 new file mode 100644 index 0000000000000000000000000000000000000000..a45b354600c1d6689acb122155077acc1c49eb42 --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/keysTab.fxml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import javafx.scene.control.*?> +<?import java.lang.*?> +<?import javafx.scene.layout.*?> + +<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.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" /> + <TableColumn fx:id="shortcutTableColumn" editable="false" minWidth="0.0" prefWidth="139.0" text="%settings.keys.table.shortcut" /> + </columns> + </TableView> + <Separator prefWidth="200.0" /> + <HBox spacing="14.0"> + <children> + <Label alignment="CENTER_RIGHT" prefWidth="150.0" text="%settings.keys.label.name" /> + <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="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> + </HBox> + </children> + <padding> + <Insets bottom="14.0" left="14.0" right="14.0" top="14.0" /> + </padding> +</VBox> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/global/updateTab.fxml similarity index 100% rename from PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/option/global/updateTab.fxml diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/midiTab_old.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/midiTab_old.fxml deleted file mode 100644 index 5923d8e0a7b57dd5fb8b9142528faf0ad80c962b..0000000000000000000000000000000000000000 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/midiTab_old.fxml +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import javafx.scene.control.*?> -<?import java.lang.*?> -<?import javafx.scene.layout.*?> - -<AnchorPane fx:id="rootPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> - <children> - <HBox layoutX="34.0" layoutY="34.0" prefHeight="67.0" prefWidth="523.0" spacing="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" AnchorPane.topAnchor="14.0"> - <children> - <VBox alignment="CENTER_RIGHT" layoutX="9.0" layoutY="19.0" prefHeight="67.0" spacing="25.0" AnchorPane.leftAnchor="14.0" AnchorPane.topAnchor="14.0"> - <children> - <Label layoutX="9.0" layoutY="19.0" text="%settings.midi.label.device" /> - <Label layoutX="11.0" layoutY="51.0" text="%settings.midi.label.preset" /> - </children> - </VBox> - <VBox layoutX="127.0" layoutY="14.0" maxWidth="1.7976931348623157E308" spacing="14.0" HBox.hgrow="ALWAYS"> - <children> - <HBox alignment="CENTER_LEFT" layoutX="127.0" layoutY="14.0" maxWidth="1.7976931348623157E308" spacing="14.0" AnchorPane.leftAnchor="127.0" AnchorPane.rightAnchor="121.0" VBox.vgrow="ALWAYS"> - <children> - <ComboBox fx:id="deviceComboBox" onAction="#deviceHandler" prefWidth="150.0" /> - <Pane HBox.hgrow="ALWAYS" /> - <CheckBox fx:id="midiActiveCheckBox" mnemonicParsing="false" text="%settings.checkbox.activate" /> - </children> - </HBox> - <HBox layoutX="127.0" layoutY="47.0" maxWidth="1.7976931348623157E308" spacing="14.0" VBox.vgrow="ALWAYS"> - <children> - <ComboBox fx:id="presetsList" layoutX="127.0" layoutY="47.0" prefWidth="150.0" /> - <Button fx:id="presetsEditButton" layoutX="304.0" layoutY="47.0" mnemonicParsing="false" onAction="#presetsEditButtonHandler" text="%settings.midi.presetEdit" /> - <Button fx:id="activateButton" mnemonicParsing="false" onAction="#activateButtonHandler" text="%settings.midi.button.activate" /> - </children> - </HBox> - </children> - </VBox> - </children> - </HBox> - <TreeView fx:id="contentTreeView" prefHeight="375.0" prefWidth="300.0" AnchorPane.bottomAnchor="135.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="90.0" /> - <ComboBox fx:id="midiActionTypeComboBox" layoutX="312.0" layoutY="90.0" prefWidth="264.0" AnchorPane.leftAnchor="314.0" /> - <AnchorPane fx:id="settingsAnchorPane" layoutX="306.0" layoutY="133.0" prefHeight="467.0" prefWidth="300.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="300.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="133.0" /> - <HBox layoutX="14.0" layoutY="534.0" prefHeight="52.0" prefWidth="281.0" spacing="14.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0"> - <children> - <VBox spacing="14.0"> - <children> - <Button fx:id="addMidiButton" defaultButton="true" layoutX="14.0" layoutY="319.0" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#addMidiButtonHandler" text="%settings.midi.button.add" AnchorPane.bottomAnchor="56.0" AnchorPane.leftAnchor="14.0" /> - <Button fx:id="addMidiDraftButton" layoutX="14.0" layoutY="354.0" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#addMidiDraftButtonHandler" text="%settings.midi.button.addDraft" AnchorPane.bottomAnchor="21.0" AnchorPane.leftAnchor="14.0" /> - <Button fx:id="draftButton" mnemonicParsing="false" onAction="#draftButtonHandler" text="%settings.midi.button.saveDraft" /> - </children> - </VBox> - <VBox spacing="14.0"> - <children> - <Button fx:id="deleteMidiButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#deleteMidiButtonHandler" text="%settings.midi.button.delete" /> - <Button fx:id="clearMidiButton" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onAction="#clearMidiButtonHandler" prefHeight="26.0" prefWidth="68.0" text="%settings.midi.button.clear" /> - </children> - </VBox> - </children> - </HBox> - </children> -</AnchorPane> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/audioTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/audioTab.fxml similarity index 100% rename from PlayWall/assets/de/tobias/playpad/assets/view/option/audioTab.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/option/profile/audioTab.fxml diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/layoutTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/layoutTab.fxml similarity index 100% rename from PlayWall/assets/de/tobias/playpad/assets/view/option/layoutTab.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/option/profile/layoutTab.fxml diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/mapping.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/mapping.fxml similarity index 100% rename from PlayWall/assets/de/tobias/playpad/assets/view/option/mapping.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/option/profile/mapping.fxml diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/midiTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/midiTab.fxml similarity index 100% rename from PlayWall/assets/de/tobias/playpad/assets/view/option/midiTab.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/option/profile/midiTab.fxml diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/playerTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/playerTab.fxml similarity index 79% rename from PlayWall/assets/de/tobias/playpad/assets/view/option/playerTab.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/option/profile/playerTab.fxml index c20941bec1301df874b09cb48d9495bc4559439a..7b9c18cdd0dd9efc3cb0cfb01910d6918e4e2717 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/playerTab.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/playerTab.fxml @@ -7,6 +7,13 @@ <VBox spacing="14.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <children> + <HBox spacing="14.0"> + <children> + <Label alignment="CENTER_RIGHT" prefWidth="150.0" text="%settings.player.label.modus" /> + <CheckBox fx:id="playerModus" layoutX="150.0" mnemonicParsing="false" text="%settings.player.checkbox.modus" /> + </children> + </HBox> + <Separator prefWidth="200.0" /> <Label text="%settings.player.label.fade" underline="true" /> <VBox fx:id="fadeContainer" minHeight="20.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" /> <Separator prefWidth="200.0" /> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/settingsView.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/profile/settingsView.fxml similarity index 100% rename from PlayWall/assets/de/tobias/playpad/assets/view/option/settingsView.fxml rename to PlayWall/assets/de/tobias/playpad/assets/view/option/profile/settingsView.fxml diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/project/generalTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/project/generalTab.fxml new file mode 100644 index 0000000000000000000000000000000000000000..846711017bc96d87dc8447291d4c5d1bcec0184a --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/project/generalTab.fxml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import java.lang.*?> +<?import javafx.scene.control.*?> +<?import javafx.scene.layout.*?> + + +<VBox spacing="14.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <children> + <Label text="%settings.gen.label.view" underline="true" /> + <HBox spacing="14.0"> + <children> + <Label alignment="BASELINE_RIGHT" layoutX="21.0" layoutY="40.0" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.pages" /> + <TextField fx:id="pageCountTextField" prefWidth="50.0" /> + </children> + </HBox> + <HBox spacing="14.0"> + <children> + <Label alignment="BASELINE_RIGHT" layoutX="20.0" layoutY="68.0" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.columns" /> + <TextField fx:id="columnTextField" prefWidth="50.0" /> + </children> + </HBox> + <HBox spacing="14.0"> + <children> + <Label alignment="BASELINE_RIGHT" layoutX="18.0" layoutY="96.0" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.rows" /> + <TextField fx:id="rowTextField" prefWidth="50.0" /> + </children> + </HBox> + </children> + <padding> + <Insets bottom="14.0" left="14.0" right="14.0" top="14.0" /> + </padding> +</VBox> 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/assets/de/tobias/playpad/assets/view/option/project/projectSettingsView.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/project/projectSettingsView.fxml new file mode 100644 index 0000000000000000000000000000000000000000..23efae52a75f75d6b931db277299917bba3eea67 --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/project/projectSettingsView.fxml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import javafx.scene.control.*?> +<?import java.lang.*?> +<?import javafx.scene.layout.*?> + +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="592.0" prefWidth="645.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <children> + <TabPane fx:id="tabPane" prefHeight="348.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="52.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> + <Button fx:id="finishButton" layoutX="508.0" layoutY="360.0" mnemonicParsing="false" onAction="#finishButtonHandler" text="%settings.button.finish" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="14.0" /> + </children> +</AnchorPane> 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 2289010683445f25ef0b0f5837f49826c95409e3..4ed0bd37d618f8b78403b3a82be171e26e437731 100644 --- a/PlayWall/src/application.yml +++ b/PlayWall/src/application.yml @@ -1,6 +1,6 @@ name: PlayWall -version: 5.0.1 -build: 32 +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 ecff8fee390fa91ea62c2ad024ff452164a7553a..83b0ae9f158a67dd7b75e20541b165c2d9be331b 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java @@ -12,18 +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.ISettingsViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; 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; @@ -34,7 +47,7 @@ public class PlayPadImpl implements PlayPad { private static final String PLUGIN_INFO_TXT = "pluginInfo.txt"; protected List<WindowListener<IMainViewController>> mainViewListeners = new ArrayList<>(); - protected List<WindowListener<ISettingsViewController>> settingsViewListeners = new ArrayList<>(); + protected List<WindowListener<IProfileSettingsViewController>> settingsViewListeners = new ArrayList<>(); protected List<WindowListener<IPadSettingsViewController>> padSettingsViewListeners = new ArrayList<>(); protected List<SettingsListener> settingsListeners = new ArrayList<>(); protected List<PadListener> padListeners = new ArrayList<>(); @@ -43,10 +56,14 @@ public class PlayPadImpl implements PlayPad { private Set<Path> deletedPlugins; private MainViewController mainViewController; + private Project currentProject; + protected GlobalSettings globalSettings; - public PlayPadImpl() { + public PlayPadImpl(GlobalSettings globalSettings) { pluginManager = PluginManagerFactory.createPluginManager(); deletedPlugins = new HashSet<>(); + + this.globalSettings = globalSettings; } @Override @@ -54,6 +71,10 @@ public class PlayPadImpl implements PlayPad { mainViewListeners.add(listener); } + public List<WindowListener<IMainViewController>> getMainViewListeners() { + return mainViewListeners; + } + @Override public void addSettingsListener(SettingsListener listener) { settingsListeners.add(listener); @@ -132,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 { @@ -148,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(); } @@ -156,11 +197,57 @@ public class PlayPadImpl implements PlayPad { pluginManager.addPluginsFrom(uri); } + @Override + public GlobalSettings getGlobalSettings() { + return globalSettings; + } + public void openProject(Project project) { if (mainViewController == null) { - mainViewController = new MainViewController(project, mainViewListeners); - } else { - mainViewController.setProject(project); + mainViewController = new MainViewController(mainViewListeners); } + currentProject = project; + mainViewController.openProject(project); + } + + 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 a399f8561daefd030f8207f3db9cedea6ae18af1..924c2c8f4c3b513b8d8673ee4fc378bb77a9bfae 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadMain.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadMain.java @@ -9,44 +9,15 @@ import java.util.Optional; import java.util.ResourceBundle; import java.util.UUID; -import de.tobias.playpad.action.ActionRegistery; -import de.tobias.playpad.action.connect.CartActionConnect; -import de.tobias.playpad.action.connect.NavigateActionConnect; -import de.tobias.playpad.action.connect.PageActionConnect; -import de.tobias.playpad.action.mapper.KeyboardMapperConnect; -import de.tobias.playpad.action.mapper.MapperRegistry; -import de.tobias.playpad.action.mapper.MidiMapperConnect; -import de.tobias.playpad.audio.AudioRegistry; -import de.tobias.playpad.audio.ClipAudioHandler; -import de.tobias.playpad.audio.ClipAudioHandlerConnect; -import de.tobias.playpad.audio.JavaFXAudioHandler; -import de.tobias.playpad.audio.JavaFXHandlerConnect; -import de.tobias.playpad.audio.TinyAudioHandler; -import de.tobias.playpad.audio.TinyAudioHandlerConnect; -import de.tobias.playpad.layout.LayoutRegistry; -import de.tobias.playpad.layout.classic.ClassicGlobalLayout; -import de.tobias.playpad.layout.classic.ClassicLayoutConnect; -import de.tobias.playpad.layout.modern.ModernLayoutConnect; -import de.tobias.playpad.midi.device.DeviceRegistry; -import de.tobias.playpad.midi.device.PD12; -import de.tobias.playpad.pad.conntent.PadContentRegistry; -import de.tobias.playpad.pad.content.AudioContentConnect; -import de.tobias.playpad.pad.drag.MoveDragMode; -import de.tobias.playpad.pad.drag.PadDragModeRegistery; -import de.tobias.playpad.pad.drag.ReplaceDragMode; import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectReference; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileListener; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.ProfileReference; -import de.tobias.playpad.tigger.TriggerRegistry; -import de.tobias.playpad.trigger.CartTriggerItemConnect; -import de.tobias.playpad.trigger.VolumeTriggerItemConnect; 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; @@ -60,38 +31,21 @@ 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 // FEATURE Backups irgendwann löschen -public class PlayPadMain extends Application implements LocalizationDelegate, ProfileListener { +public class PlayPadMain extends Application implements LocalizationDelegate { private static final String iconPath = "icon_small.png"; public static Optional<Image> stageIcon = Optional.empty(); @@ -106,7 +60,7 @@ public class PlayPadMain extends Application implements LocalizationDelegate, Pr private static PlayPadImpl impl; private static PlayPadUpdater updater; - + public static ResourceBundle getUiResourceBundle() { return uiResourceBundle; } @@ -128,68 +82,104 @@ public class PlayPadMain extends Application implements LocalizationDelegate, Pr @Override public void init() throws Exception { - impl = new PlayPadImpl(); + App app = ApplicationUtils.getApplication(); + + Path globalSettingsPath = app.getPath(PathType.CONFIGURATION, "GlobalSettings.yml"); + GlobalSettings globalSettings = GlobalSettings.load(globalSettingsPath); + + impl = new PlayPadImpl(globalSettings); PlayPadPlugin.setImplementation(impl); + PlayPadPlugin.setRegistryCollection(new RegistryCollectionImpl()); // Localization setupLocalization(); // Console - if (!ApplicationUtils.getApplication().isDebug()) { - System.setOut(ConsoleUtils.streamToFile(ApplicationUtils.getApplication().getPath(PathType.LOG, "out.log"))); - System.setErr(ConsoleUtils.streamToFile(ApplicationUtils.getApplication().getPath(PathType.LOG, "err.log"))); + if (!app.isDebug()) { + System.setOut(ConsoleUtils.streamToFile(app.getPath(PathType.LOG, "out.log"))); + System.setErr(ConsoleUtils.streamToFile(app.getPath(PathType.LOG, "err.log"))); } } @Override - public void start(Stage stage) throws Exception { - // Assets + public void start(Stage stage) { try { - Image stageIcon = new Image(iconPath); - PlayPadMain.stageIcon = Optional.of(stageIcon); - } catch (Exception e) {} - - /* - * Setup - */ - updater = new PlayPadUpdater(); - UpdateRegistery.registerUpdateable(updater); - registerComponents(); - - // Load Plugin Path - Path pluginFolder; - if (getParameters().getNamed().containsKey("plugin")) { - pluginFolder = Paths.get(getParameters().getNamed().get("plugin")); - } else { - pluginFolder = ApplicationUtils.getApplication().getPath(PathType.LIBRARY); - } - setupPlugins(pluginFolder); + // Assets + try { + Image stageIcon = new Image(iconPath); + PlayPadMain.stageIcon = Optional.of(stageIcon); + } catch (Exception e) {} + + /* + * Setup + */ + updater = new PlayPadUpdater(); + UpdateRegistery.registerUpdateable(updater); + + impl.startup(uiResourceBundle); + + // Load Plugin Path + Path pluginFolder; + if (getParameters().getNamed().containsKey("plugin")) { + pluginFolder = Paths.get(getParameters().getNamed().get("plugin")); + } else { + pluginFolder = ApplicationUtils.getApplication().getPath(PathType.LIBRARY); + } + setupPlugins(pluginFolder); - /* - * Load Data - */ - ProfileReference.loadProfiles(); - ProjectReference.loadProjects(); + /* + * Load Data + */ + ProfileReference.loadProfiles(); + ProjectReference.loadProjects(); - // Changelog nach Update anzeigen - try { + // Changelog nach Update anzeigen ViewController.create(ChangelogDialog.class); + + // Auto Open Project + if (getParameters().getRaw().size() > 0) { + if (getParameters().getNamed().containsKey("project")) { + UUID uuid = UUID.fromString(getParameters().getNamed().get("project")); + impl.openProject(Project.load(ProjectReference.getProject(uuid), true, null)); + return; + } + } + + // Zeigt Launch Stage + ViewController.create(LaunchDialog.class, stage); + + // Check Updates + checkUpdates(impl.globalSettings, stage); + } catch (Exception e) { e.printStackTrace(); } + } - // Auto Open Project - if (getParameters().getRaw().size() > 0) { - try { - UUID uuid = UUID.fromString(getParameters().getNamed().get("project")); - impl.openProject(Project.load(ProjectReference.getProject(uuid), true, null)); - return; - } catch (IllegalArgumentException | NullPointerException e) {} catch (Exception e) { - e.printStackTrace(); - } + private void checkUpdates(GlobalSettings globalSettings, Window owner) { + if (globalSettings.isAutoUpdate() && !globalSettings.isIgnoreUpdate()) { + Worker.runLater(() -> + { + UpdateRegistery.lookupUpdates(globalSettings.getUpdateChannel()); + if (!UpdateRegistery.getAvailableUpdates().isEmpty()) { + Platform.runLater(() -> + { + AutoUpdateDialog autoUpdateDialog = new AutoUpdateDialog(owner); + autoUpdateDialog.showAndWait().filter(item -> item == ButtonType.APPLY).ifPresent(result -> + { + try { + Updates.startUpdate(); + } catch (IOException e) { + e.printStackTrace(); + } + }); + if (autoUpdateDialog.isSelected()) { + globalSettings.setIgnoreUpdate(true); + } + }); + } + }); } - - ViewController.create(LaunchDialog.class, stage); } @Override @@ -197,61 +187,17 @@ public class PlayPadMain extends Application implements LocalizationDelegate, Pr try { ProfileReference.saveProfiles(); ProjectReference.saveProjects(); + impl.getGlobalSettings().save(); } catch (Exception e) { e.printStackTrace(); // Speichern Fehler } - // Shutdown components - // TODO use AutoCloseable - TinyAudioHandler.shutdown(); - ClipAudioHandler.shutdown(); - impl.shutdown(); Platform.exit(); System.exit(0); } - private void registerComponents() { - // Audio - AudioRegistry.register(new JavaFXHandlerConnect(), JavaFXAudioHandler.NAME); - AudioRegistry.register(new TinyAudioHandlerConnect(), TinyAudioHandler.NAME); - AudioRegistry.register(new ClipAudioHandlerConnect(), ClipAudioHandler.NAME); - - AudioRegistry.setDefaultAudioInterface(JavaFXAudioHandler.NAME); - - // Layout - LayoutRegistry.registerLayout(new ClassicLayoutConnect()); - LayoutRegistry.registerLayout(new ModernLayoutConnect()); - LayoutRegistry.setDefaultLayout(ClassicGlobalLayout.TYPE); - - // Midi - DeviceRegistry.getFactoryInstance().registerDevice(PD12.NAME, PD12.class); - - // Trigger - TriggerRegistry.register(new CartTriggerItemConnect()); - TriggerRegistry.register(new VolumeTriggerItemConnect()); - - // Actions - ActionRegistery.registerActionConnect(new CartActionConnect()); - ActionRegistery.registerActionConnect(new PageActionConnect()); - ActionRegistery.registerActionConnect(new NavigateActionConnect()); - - // Mapper - MapperRegistry.registerMapperConnect(new MidiMapperConnect()); - MapperRegistry.registerMapperConnect(new KeyboardMapperConnect()); - MapperRegistry.setOverviewViewController(new MapperOverviewViewController()); - - // Pad Content - PadContentRegistry.registerActionConnect(new AudioContentConnect()); - - // Pad Drag Mode - PadDragModeRegistery.registerActionConnect(new MoveDragMode()); - PadDragModeRegistery.registerActionConnect(new ReplaceDragMode()); - - Profile.registerListener(this); - } - private void setupPlugins(Path pluginPath) throws IOException, MalformedURLException { // Delete old plugins impl.deletePlugins(); @@ -267,36 +213,6 @@ public class PlayPadMain extends Application implements LocalizationDelegate, Pr uiResourceBundle = Localization.loadBundle("de/tobias/playpad/assets/lang/ui", getClass().getClassLoader()); } - /** - * Handle Auto Update on profile reload - */ - @Override - public void reloadSettings(Profile oldProfile, Profile newProfile) { - // Update PlayWall - if (newProfile.getProfileSettings().isAutoUpdate()) { - Worker.runLater(() -> - { - UpdateRegistery.lookupUpdates(newProfile.getProfileSettings().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 -> - { - try { - Updates.startUpdate(); - } catch (IOException e) { - e.printStackTrace(); - } - }); - }); - } - }); - } - } - @Override public String getBaseResource() { return "de/tobias/playpad/assets/lang/"; diff --git a/PlayWall/src/de/tobias/playpad/RegistryCollectionImpl.java b/PlayWall/src/de/tobias/playpad/RegistryCollectionImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..12d4b0fe594f1c12be839fa66fd6f129c1424acc --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/RegistryCollectionImpl.java @@ -0,0 +1,78 @@ +package de.tobias.playpad; + +import de.tobias.playpad.action.ActionConnect; +import de.tobias.playpad.action.mapper.MapperConnect; +import de.tobias.playpad.audio.AudioRegistry; +import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.pad.PadContentRegistry; +import de.tobias.playpad.pad.drag.PadDragMode; +import de.tobias.playpad.registry.ComponentRegistry; +import de.tobias.playpad.registry.DefaultComponentRegistry; +import de.tobias.playpad.registry.DefaultRegistry; +import de.tobias.playpad.registry.Registry; +import de.tobias.playpad.tigger.TriggerItemConnect; +import de.tobias.playpad.view.main.MainLayoutConnect; + +public class RegistryCollectionImpl implements RegistryCollection { + + private Registry<ActionConnect> actionRegistry; + private AudioRegistry audioHandlerRegistry; + private Registry<PadDragMode> dragModeRegistry; + private DefaultRegistry<DesignConnect> layoutRegistry; + private Registry<MapperConnect> mapperRegistry; + private PadContentRegistry padContentRegistry; + private Registry<TriggerItemConnect> triggerItemRegistry; + private DefaultRegistry<MainLayoutConnect> mainLayoutRegistry; + + public RegistryCollectionImpl() { + actionRegistry = new ComponentRegistry<>("Action"); + audioHandlerRegistry = new AudioRegistry(); + dragModeRegistry = new ComponentRegistry<>("DragMode"); + layoutRegistry = new DefaultComponentRegistry<>("Layout"); + mapperRegistry = new ComponentRegistry<>("Mapper"); + padContentRegistry = new PadContentRegistry("PadContent"); + triggerItemRegistry = new ComponentRegistry<>("Trigger"); + mainLayoutRegistry = new DefaultComponentRegistry<>("MainLayout"); + } + + @Override + public Registry<ActionConnect> getActions() { + return actionRegistry; + } + + @Override + public AudioRegistry getAudioHandlers() { + return audioHandlerRegistry; + } + + @Override + public Registry<PadDragMode> getDragModes() { + return dragModeRegistry; + } + + @Override + public DefaultRegistry<DesignConnect> getDesigns() { + return layoutRegistry; + } + + @Override + public Registry<MapperConnect> getMappers() { + return mapperRegistry; + } + + @Override + public PadContentRegistry getPadContents() { + return padContentRegistry; + } + + @Override + public Registry<TriggerItemConnect> getTriggerItems() { + return triggerItemRegistry; + } + + @Override + public DefaultRegistry<MainLayoutConnect> getMainLayouts() { + return mainLayoutRegistry; + } + +} diff --git a/PlayWall/src/de/tobias/playpad/Strings.java b/PlayWall/src/de/tobias/playpad/Strings.java index 57939d09a2c2bce4bdf1d6224442c71a52bc7070..ecd9bf62c80aef675ee7fd54034d9ed29e3282c5 100644 --- a/PlayWall/src/de/tobias/playpad/Strings.java +++ b/PlayWall/src/de/tobias/playpad/Strings.java @@ -21,6 +21,8 @@ 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"; public static final String UI_Dialog_DragAndDrop_Title = "UI.Dialog.DragAndDrop.Title"; @@ -44,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"; @@ -60,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"; @@ -139,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."; @@ -167,6 +173,10 @@ public class Strings { // Info - Mapper 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"; @@ -194,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."; @@ -203,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 @@ -223,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/VersionUpdater.java b/PlayWall/src/de/tobias/playpad/VersionUpdater.java index 045a3e7e96923ead258ea4fe3155db83d020843a..7cc6280d1f22f6614e5207f330a1a37afc2f2e0e 100644 --- a/PlayWall/src/de/tobias/playpad/VersionUpdater.java +++ b/PlayWall/src/de/tobias/playpad/VersionUpdater.java @@ -1,34 +1,19 @@ package de.tobias.playpad; import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; import java.util.UUID; import org.dom4j.Document; import org.dom4j.DocumentException; -import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; -import de.tobias.playpad.action.Mapping; -import de.tobias.playpad.action.MappingSerializer; -import de.tobias.playpad.action.cartaction.CartAction; -import de.tobias.playpad.action.cartaction.CartAction.ControlMode; -import de.tobias.playpad.action.feedback.DoubleSimpleFeedback; -import de.tobias.playpad.action.mapper.MidiMapper; -import de.tobias.playpad.project.Project; -import de.tobias.playpad.project.ProjectReference; -import de.tobias.playpad.settings.ProfileReference; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.utils.application.App; -import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; import de.tobias.utils.application.update.UpdateService; @@ -36,202 +21,56 @@ public class VersionUpdater implements UpdateService { @Override public void update(App app, long oldVersion, long newVersion) { - update18(oldVersion); - update23(app, oldVersion); - } - - private void update23(App app, long oldVersion) { - if (oldVersion <= 23) { - Path configPath = app.getPath(PathType.CONFIGURATION); - SAXReader reader = new SAXReader(); - try { - Document document = reader.read(Files.newInputStream(configPath.resolve("Profiles.xml"))); - for (Object profileObj : document.getRootElement().elements("Profile")) { - if (profileObj instanceof Element) { - String name = ((Element) profileObj).getStringValue(); - System.out.println("Start Profile: " + name); - UUID uuid = UUID.randomUUID(); - - Path profileOldPath = app.getPath(PathType.CONFIGURATION, name); - Path profileNewPath = app.getPath(PathType.CONFIGURATION, uuid.toString()); - - Files.move(profileOldPath, profileNewPath); - - convertMidiToMapping(profileNewPath); - - ProfileReference profileReference = new ProfileReference(uuid, name); - ProfileReference.addProfile(profileReference); - System.out.println("Finish Profile: " + name + " (" + uuid + ")"); - } - } - } catch (DocumentException | IOException e1) { - e1.printStackTrace(); - } - - try { - Document document = reader.read(Files.newInputStream(configPath.resolve("Projects.xml"))); - for (Object projectObj : document.getRootElement().elements("Project")) { - if (projectObj instanceof Element) { - try { - String name = ((Element) projectObj).getStringValue(); - Path projectPath = app.getPath(PathType.DOCUMENTS, name); - System.out.println("Start Project: " + projectPath); - - UUID uuid = UUID.randomUUID(); - Path newProjectPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, uuid + Project.FILE_EXTENSION); - - Files.move(projectPath, newProjectPath); - - ProjectReference projectReference = new ProjectReference(uuid, projectPath.getFileName().toString(), - ProfileReference.getProfiles().get(0)); - ProjectReference.addProject(projectReference); - - convertProject(newProjectPath); - System.out.println("End Project: " + projectPath + " (" + uuid + ")"); - } catch (DocumentException | URISyntaxException e) { - e.printStackTrace(); - } - } - } - } catch (IOException | DocumentException e) { - e.printStackTrace(); - } - try { - ProfileReference.saveProfiles(); - ProjectReference.saveProjects(); - } catch (IOException e) { - e.printStackTrace(); - } + try { + if (newVersion >= 33 && oldVersion < 33) + update33(app); + } catch (Exception e) { + e.printStackTrace(); } } - private void update18(long oldVersion) { - if (oldVersion <= 18) { - SAXReader reader = new SAXReader(); - Path path = ApplicationUtils.getApplication().getPath(PathType.CONFIGURATION, "Profiles.xml"); - - try { - Document document = reader.read(Files.newInputStream(path)); - Element root = document.getRootElement(); - for (Object object : root.elements("Document")) { - Element element = (Element) object; - String name = element.getStringValue(); - - UUID uuid = UUID.randomUUID(); - - Path projectPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, name); - Path newProjectPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, uuid + Project.FILE_EXTENSION); - Files.createDirectories(newProjectPath.getParent()); - - Files.move(projectPath, newProjectPath); + private void update33(App app) throws DocumentException, IOException { + SAXReader reader = new SAXReader(); - ProjectReference projectReference = new ProjectReference(uuid, name, ProfileReference.getProfiles().get(0)); - ProjectReference.addProject(projectReference); + Document projectsDocument = reader.read(Files.newInputStream(app.getPath(PathType.CONFIGURATION, "Projects.xml"))); + for (Object obj : projectsDocument.getRootElement().elements("Project")) { + if (obj instanceof Element) { + Element element = (Element) obj; - convertProject(newProjectPath); - } + UUID profile = UUID.fromString(element.attributeValue("profile")); + UUID project = UUID.fromString(element.attributeValue("uuid")); - ProjectReference.saveProjects(); - } catch (Exception e) { - e.printStackTrace(); + updateProject(profile, project, app); } } } - public void convertMidiToMapping(Path configPath) throws DocumentException, IOException { + private void updateProject(UUID profile, UUID project, App app) throws DocumentException, IOException { + Path profileSettings = app.getPath(PathType.CONFIGURATION, profile.toString(), "ProfileSettings.xml"); SAXReader reader = new SAXReader(); - Document midiDocument = reader.read(Files.newInputStream(configPath.resolve("Midi.xml"))); - - List<Mapping> mappings = new ArrayList<>(); - - for (Object presetObj : midiDocument.getRootElement().elements("Preset")) { - Element presetElement = (Element) presetObj; - String name = presetElement.attributeValue("name"); - - Mapping mapping = new Mapping(false, null); - mapping.setName(name); - mapping.setUuid(UUID.randomUUID()); - - for (Object midiObj : presetElement.elements("Midi")) { - Element midiElement = (Element) midiObj; - int command = Integer.valueOf(midiElement.attributeValue("command")); - int key = Integer.valueOf(midiElement.attributeValue("channel")); - if (midiElement.attributeValue("type") != null) { - if (midiElement.attributeValue("type").equals("de.tobias.playpad.model.midi.type.PlayStopActionType")) { - Element actionElement = midiElement.element("Action"); - if (actionElement.attributeValue("class").equals("de.tobias.playpad.model.midi.CartAction")) { - int cart = Integer.valueOf(actionElement.element("CartID").getStringValue()); + Document document = reader.read(Files.newInputStream(profileSettings)); + Element rootElement = document.getRootElement(); - CartAction action = new CartAction(cart, ControlMode.PLAY_STOP); - mapping.addActionIfNotContains(action); + int pages = Integer.valueOf(rootElement.element("PageCount").getStringValue()); + int rows = Integer.valueOf(rootElement.element("Rows").getStringValue()); + int columns = Integer.valueOf(rootElement.element("Columns").getStringValue()); - MidiMapper mapper = new MidiMapper(command, key); - action.addMapper(mapper); + Path projectSettings = app.getPath(PathType.DOCUMENTS, project.toString() + ".xml"); + Document projectDocument = reader.read(Files.newInputStream(projectSettings)); + Element rootProjectElement = projectDocument.getRootElement(); + Element settingsElement = rootProjectElement.addElement("Settings"); - Element feedbackEventElement = actionElement.element("Feedback"); - Element feedbackDefaultElement = midiElement.element("Feedback"); + ProjectSettings projectSettings2 = new ProjectSettings(); + projectSettings2.setColumns(columns); + projectSettings2.setRows(rows); + projectSettings2.setPageCount(pages); - int feedbackEvent = Integer.valueOf(feedbackEventElement.element("MidiVelocity").getStringValue()); - int feedbackDefault = Integer.valueOf(feedbackDefaultElement.element("MidiVelocity").getStringValue()); + projectSettings2.save(settingsElement); - DoubleSimpleFeedback doubleSimpleFeedback = new DoubleSimpleFeedback(feedbackDefault, feedbackEvent); - mapper.setFeedback(doubleSimpleFeedback); - } - } - } - } - mappings.add(mapping); - } - - Document mappingDocument = DocumentHelper.createDocument(); - Element rootElement = mappingDocument.addElement("List"); - - for (Mapping mapping : mappings) { - Element mappingElement = rootElement.addElement("Mapping"); - - MappingSerializer mappingSerializer = new MappingSerializer(); - mappingSerializer.saveElement(mappingElement, mapping); - } - - XMLWriter writer = new XMLWriter(Files.newOutputStream(configPath.resolve("Mapping.xml")), OutputFormat.createPrettyPrint()); - writer.write(mappingDocument); + XMLWriter writer = new XMLWriter(Files.newOutputStream(projectSettings), OutputFormat.createPrettyPrint()); + writer.write(projectDocument); writer.close(); - - Files.delete(configPath.resolve("Midi.xml")); } - public void convertProject(Path path) throws DocumentException, IOException, URISyntaxException { - SAXReader reader = new SAXReader(); - Document oldDocument = reader.read(Files.newInputStream(path)); - Document newDocument = DocumentHelper.createDocument(); - - Element newRootElement = newDocument.addElement("Project"); - - for (Object oldPadObj : oldDocument.getRootElement().elements("Pad")) { - try { - Element oldPadElement = (Element) oldPadObj; - Element newPadElement = newRootElement.addElement("Pad"); - - newPadElement.addAttribute("index", oldPadElement.attributeValue("index")); - newPadElement.addAttribute("name", oldPadElement.element("Title").getStringValue()); - newPadElement.addAttribute("status", oldPadElement.element("State").getStringValue()); - - String file = oldPadElement.element("Path").getStringValue(); - URI uri = new URI(file); - newPadElement.addElement("Content").addAttribute("type", "audio").addText(Paths.get(uri).toString()); - - Element newSettingsElement = newPadElement.addElement("Settings"); - newSettingsElement.addElement("Volume").addText(oldPadElement.element("Volume").getStringValue()); - newSettingsElement.addElement("Loop").addText(oldPadElement.element("Loop").getStringValue()); - if (oldPadElement.element("TimeMode") != null) - newSettingsElement.addElement("TimeMode").addText(oldPadElement.element("TimeMode").getStringValue()); - } catch (Exception e) { - } - } - - XMLWriter writer = new XMLWriter(Files.newOutputStream(path), OutputFormat.createPrettyPrint()); - writer.write(newDocument); - writer.close(); - } } diff --git a/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java b/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java index 08b415006500178cd7ef058c11e9175e27d19833..b6cc56cdb510a9ee0cca3e9a6798661221e92150 100644 --- a/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java +++ b/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java @@ -6,10 +6,11 @@ import de.tobias.playpad.Strings; import de.tobias.playpad.action.Action; import de.tobias.playpad.action.InputType; import de.tobias.playpad.action.connect.CartActionConnect; +import de.tobias.playpad.action.feedback.ColorAdjustable; import de.tobias.playpad.action.feedback.FeedbackType; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.pad.conntent.Durationable; +import de.tobias.playpad.pad.conntent.play.Durationable; import de.tobias.playpad.project.Project; import de.tobias.playpad.viewcontroller.actions.CartActionViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; @@ -18,7 +19,7 @@ import de.tobias.utils.util.Localization; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; -public class CartAction extends Action { +public class CartAction extends Action implements ColorAdjustable { public enum ControlMode { PLAY_PAUSE, @@ -26,7 +27,9 @@ public class CartAction extends Action { PLAY_HOLD; } - private int cart; + private int x; + private int y; + private ControlMode mode; private boolean autoFeedbackColors; @@ -36,23 +39,27 @@ public class CartAction extends Action { private transient PadPositionWarningListener padPositionListener = new PadPositionWarningListener(this); public CartAction() { - this.cart = 0; + this.x = 0; + this.y = 0; + this.mode = ControlMode.PLAY_STOP; this.autoFeedbackColors = true; } - public CartAction(int cart, ControlMode mode) { - this.cart = cart; + public CartAction(int x, int y, ControlMode mode) { + this.x = x; + this.y = y; + this.mode = mode; this.autoFeedbackColors = true; } - public int getCart() { - return cart; + public int getX() { + return x; } - public void setCart(int cart) { - this.cart = cart; + public int getY() { + return y; } public ControlMode getMode() { @@ -63,6 +70,7 @@ public class CartAction extends Action { this.mode = mode; } + @Override public boolean isAutoFeedbackColors() { return autoFeedbackColors; } @@ -72,16 +80,20 @@ public class CartAction extends Action { } // Helper + @Override public Pad getPad() { return pad; } @Override public void initFeedback(Project project, IMainViewController controller) { - Pad pad = project.getPad(cart); - setPad(pad); - // init first feedback - padStatusFeedbackListener.changed(null, null, pad.getStatus()); + Pad pad = project.getPad(x, y, controller.getPage()); + + if (pad != null) { + setPad(pad); + // init first feedback + padStatusFeedbackListener.changed(null, null, pad.getStatus()); + } } @Override @@ -93,7 +105,7 @@ public class CartAction extends Action { public boolean equals(Object obj) { if (obj instanceof CartAction) { CartAction action2 = (CartAction) obj; - if (action2.cart == cart) { + if (action2.x == x && action2.y == y) { return true; } } @@ -107,7 +119,7 @@ public class CartAction extends Action { @Override public void performAction(InputType type, Project project, IMainViewController mainViewController) { - setPad(project.getPad(cart)); + setPad(project.getPad(x, y, mainViewController.getPage())); // wird nur ausgeführt, wenn das Pad ein Content hat und sichtbar in der GUI (Gilt für MIDI und Keyboard) if (pad.getContent() != null && pad.getContent().isPadLoaded() && pad.isPadVisible()) { @@ -161,20 +173,25 @@ public class CartAction extends Action { return FeedbackType.DOUBLE; } - private static final String CART_ID = "id"; + private static final String X_ATTR = "x"; + private static final String Y_ATTR = "y"; private static final String CONTROL_MDOE = "mode"; private static final String AUTO_FEEDBACK_COLORS = "autoColor"; @Override public void load(Element root) { - cart = Integer.valueOf(root.attributeValue(CART_ID)); + if (root.attributeValue(X_ATTR) != null) + x = Integer.valueOf(root.attributeValue(X_ATTR)); + if (root.attributeValue(Y_ATTR) != null) + y = Integer.valueOf(root.attributeValue(Y_ATTR)); mode = ControlMode.valueOf(root.attributeValue(CONTROL_MDOE)); autoFeedbackColors = Boolean.valueOf(root.attributeValue(AUTO_FEEDBACK_COLORS)); } @Override public void save(Element root) { - root.addAttribute(CART_ID, String.valueOf(cart)); + root.addAttribute(X_ATTR, String.valueOf(x)); + root.addAttribute(Y_ATTR, String.valueOf(y)); root.addAttribute(CONTROL_MDOE, mode.name()); root.addAttribute(AUTO_FEEDBACK_COLORS, String.valueOf(autoFeedbackColors)); } @@ -225,7 +242,8 @@ public class CartAction extends Action { CartAction action = (CartAction) super.clone(); action.autoFeedbackColors = autoFeedbackColors; - action.cart = cart; + action.x = x; + action.y = y; action.mode = mode; return action; @@ -234,7 +252,7 @@ public class CartAction extends Action { // UI Helper @Override public String toString() { - return Localization.getString(Strings.Action_Cart_toString, String.valueOf(cart + 1)); + return Localization.getString(Strings.Action_Cart_toString, String.valueOf(x) + ", " + String.valueOf(y)); } @Override diff --git a/PlayWall/src/de/tobias/playpad/action/cartaction/PadContentFeedbackListener.java b/PlayWall/src/de/tobias/playpad/action/cartaction/PadContentFeedbackListener.java index f24c40dc7823a1e352a4543290c9f64817f381f4..d093406173742b4c4afc2775955debdd58f25716 100644 --- a/PlayWall/src/de/tobias/playpad/action/cartaction/PadContentFeedbackListener.java +++ b/PlayWall/src/de/tobias/playpad/action/cartaction/PadContentFeedbackListener.java @@ -1,7 +1,7 @@ package de.tobias.playpad.action.cartaction; -import de.tobias.playpad.pad.conntent.Durationable; import de.tobias.playpad.pad.conntent.PadContent; +import de.tobias.playpad.pad.conntent.play.Durationable; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; diff --git a/PlayWall/src/de/tobias/playpad/action/cartaction/PadPositionWarningListener.java b/PlayWall/src/de/tobias/playpad/action/cartaction/PadPositionWarningListener.java index cd3d5a1021f4e379b978844636a7547ed5a8c4f2..7bd14fdcdc4b151f2a70ab7869209333f9b224e7 100644 --- a/PlayWall/src/de/tobias/playpad/action/cartaction/PadPositionWarningListener.java +++ b/PlayWall/src/de/tobias/playpad/action/cartaction/PadPositionWarningListener.java @@ -2,7 +2,8 @@ package de.tobias.playpad.action.cartaction; import de.tobias.playpad.action.feedback.FeedbackMessage; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.conntent.Durationable; +import de.tobias.playpad.pad.PadSettings; +import de.tobias.playpad.pad.conntent.play.Durationable; import de.tobias.playpad.settings.Warning; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -29,11 +30,12 @@ public class PadPositionWarningListener implements ChangeListener<Duration> { if (pad != null && pad.isPadVisible()) { if (pad.getContent() instanceof Durationable) { Durationable durationable = (Durationable) pad.getContent(); + PadSettings padSettings = pad.getPadSettings(); // Warning nur wenn kein Loop - if (!pad.isLoop()) { + if (!padSettings.isLoop()) { // Warning - Warning warning = pad.getWarning(); + Warning warning = padSettings.getWarning(); Duration totalDuration = durationable.getDuration(); if (totalDuration != null) { Duration rest = totalDuration.subtract(newValue); diff --git a/PlayWall/src/de/tobias/playpad/action/cartaction/PadStatusFeedbackListener.java b/PlayWall/src/de/tobias/playpad/action/cartaction/PadStatusFeedbackListener.java index 2dcc8211312456283a3ab3d6076a252f66ce5a50..dfafdc97e589aaf83718dd8d2f0e707cfc6bdc12 100644 --- a/PlayWall/src/de/tobias/playpad/action/cartaction/PadStatusFeedbackListener.java +++ b/PlayWall/src/de/tobias/playpad/action/cartaction/PadStatusFeedbackListener.java @@ -2,8 +2,9 @@ package de.tobias.playpad.action.cartaction; import de.tobias.playpad.action.feedback.FeedbackMessage; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.pad.conntent.Durationable; +import de.tobias.playpad.pad.conntent.play.Durationable; import de.tobias.playpad.settings.Warning; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -37,8 +38,10 @@ public class PadStatusFeedbackListener implements ChangeListener<PadStatus> { try { if (pad.getContent() instanceof Durationable) { Durationable durationable = (Durationable) pad.getContent(); - if (!pad.isLoop()) { - Warning warning = pad.getWarning(); + PadSettings padSettings = pad.getPadSettings(); + + if (!padSettings.isLoop()) { + Warning warning = padSettings.getWarning(); Duration rest = durationable.getDuration().subtract(durationable.getPosition()); double seconds = rest.toSeconds(); diff --git a/PlayWall/src/de/tobias/playpad/action/connect/CartActionConnect.java b/PlayWall/src/de/tobias/playpad/action/connect/CartActionConnect.java index 6ceffddd45ab3f71657482af6db248b1deaa623f..b8936b0faa84a7b9056eeaf9ee001fd10eae5b40 100644 --- a/PlayWall/src/de/tobias/playpad/action/connect/CartActionConnect.java +++ b/PlayWall/src/de/tobias/playpad/action/connect/CartActionConnect.java @@ -10,8 +10,8 @@ import de.tobias.playpad.action.ActionType; import de.tobias.playpad.action.Mapping; import de.tobias.playpad.action.cartaction.CartAction; import de.tobias.playpad.action.cartaction.CartAction.ControlMode; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.viewcontroller.IMappingTabViewController; import de.tobias.playpad.viewcontroller.actions.CartActionsViewController; import de.tobias.utils.ui.ContentViewController; @@ -35,12 +35,12 @@ public class CartActionConnect extends ActionConnect implements ActionDisplayabl @Override public void initActionType(Mapping mapping, Profile profile) { - ProfileSettings profileSettings = profile.getProfileSettings(); - int pads = profileSettings.getColumns() * profileSettings.getRows() * profileSettings.getPageCount(); + for (int x = 0; x < ProjectSettings.MAX_COLUMNS; x++) { + for (int y = 0; y < ProjectSettings.MAX_ROWS; y++) { + CartAction action = new CartAction(x, y, ControlMode.PLAY_STOP); + mapping.addActionIfNotContains(action); + } - for (int i = 0; i < pads; i++) { - CartAction action = new CartAction(i, ControlMode.PLAY_STOP); - mapping.addActionIfNotContains(action); } } diff --git a/PlayWall/src/de/tobias/playpad/action/connect/PageActionConnect.java b/PlayWall/src/de/tobias/playpad/action/connect/PageActionConnect.java index 7323dca268b9da3fb05725de777c13f833ba21ec..982f9799f9dbbf871a73714a271f761e81a249df 100644 --- a/PlayWall/src/de/tobias/playpad/action/connect/PageActionConnect.java +++ b/PlayWall/src/de/tobias/playpad/action/connect/PageActionConnect.java @@ -10,8 +10,8 @@ import de.tobias.playpad.action.ActionDisplayable; import de.tobias.playpad.action.ActionType; import de.tobias.playpad.action.Mapping; import de.tobias.playpad.action.actions.PageAction; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileSettings; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -50,9 +50,7 @@ public class PageActionConnect extends ActionConnect implements ActionDisplayabl @Override public void initActionType(Mapping mapping, Profile profile) { - ProfileSettings profileSettings = profile.getProfileSettings(); - int pages = profileSettings.getPageCount(); - for (int i = 0; i < pages; i++) { + for (int i = 0; i < ProjectSettings.MAX_PAGES; i++) { PageAction action = new PageAction(i); mapping.addActionIfNotContains(action); } diff --git a/PlayWall/src/de/tobias/playpad/action/mapper/KeyboardMapper.java b/PlayWall/src/de/tobias/playpad/action/mapper/KeyboardMapper.java index 4777e9ef78d5aaf08b4e5b9e999a49e2ab6626ba..cdc25969f5935c889785b2f9cbfa3ba1a717dc5e 100644 --- a/PlayWall/src/de/tobias/playpad/action/mapper/KeyboardMapper.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/KeyboardMapper.java @@ -60,10 +60,6 @@ public class KeyboardMapper extends Mapper { } } - // Not Used for Keyboards - @Override - protected void initFeedback() {} - private static final String KEY = "key"; private static final String CODE = "code"; @@ -74,7 +70,7 @@ public class KeyboardMapper extends Mapper { } @Override - public void save(Element element, Action action) { + public void save(Element element) { element.addAttribute(KEY, key); element.addAttribute(CODE, code.name()); } diff --git a/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java b/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java index ebde690e52f56a3f0d43702a4e3a7a64890a75a3..f6f60e3937638419efae957f1133e34df713eee7 100644 --- a/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java @@ -8,11 +8,11 @@ import de.tobias.playpad.Strings; import de.tobias.playpad.action.Action; import de.tobias.playpad.action.feedback.ColorAssociator; import de.tobias.playpad.action.feedback.DisplayableFeedbackColor; -import de.tobias.playpad.action.feedback.DoubleSimpleFeedback; import de.tobias.playpad.action.feedback.Feedback; import de.tobias.playpad.action.feedback.FeedbackMessage; import de.tobias.playpad.action.feedback.FeedbackType; -import de.tobias.playpad.action.feedback.SingleSimpleFeedback; +import de.tobias.playpad.action.mapper.feedback.DoubleMidiFeedback; +import de.tobias.playpad.action.mapper.feedback.SingleMidiFeedback; import de.tobias.playpad.action.mididevice.Device; import de.tobias.playpad.action.mididevice.DeviceColorAssociatorConnector; import de.tobias.playpad.midi.Midi; @@ -63,12 +63,12 @@ public class MidiMapper extends Mapper implements ColorAssociator, MapperFeedbac } @Override - protected void initFeedback() { + public void initFeedback() { if (feedback == null || this.feedbackType != super.feedbackType) { if (super.feedbackType == FeedbackType.SINGLE) { - feedback = new SingleSimpleFeedback(); + feedback = new SingleMidiFeedback(); } else if (super.feedbackType == FeedbackType.DOUBLE) { - feedback = new DoubleSimpleFeedback(); + feedback = new DoubleMidiFeedback(); } } this.feedbackType = super.feedbackType; @@ -77,7 +77,8 @@ public class MidiMapper extends Mapper implements ColorAssociator, MapperFeedbac public Feedback getFeedback() { return feedback; } - + + @Deprecated public void setFeedback(Feedback feedback) { this.feedback = feedback; } @@ -185,7 +186,7 @@ public class MidiMapper extends Mapper implements ColorAssociator, MapperFeedbac } @Override - public void save(Element element, Action action) { + public void save(Element element) { element.addAttribute(MIDI_COMMAND, String.valueOf(command)); element.addAttribute(MIDI_KEY, String.valueOf(key)); diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/DoubleSimpleFeedback.java b/PlayWall/src/de/tobias/playpad/action/mapper/feedback/DoubleMidiFeedback.java similarity index 81% rename from PlayWallCore/src/de/tobias/playpad/action/feedback/DoubleSimpleFeedback.java rename to PlayWall/src/de/tobias/playpad/action/mapper/feedback/DoubleMidiFeedback.java index e82b05b1b7e16d1f9d09fa8ed9d55e7e9df33db1..3e16e53d3726d6cf9ba7f0ee881d39c095c43406 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/DoubleSimpleFeedback.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/feedback/DoubleMidiFeedback.java @@ -1,20 +1,31 @@ -package de.tobias.playpad.action.feedback; +package de.tobias.playpad.action.mapper.feedback; import org.dom4j.Element; -public class DoubleSimpleFeedback extends Feedback { +import de.tobias.playpad.action.feedback.Feedback; +import de.tobias.playpad.action.feedback.FeedbackMessage; + +/** + * Implementierung eines 2 State Feedbacks für MIDI Geräte. + * + * @author tobias + * + * @since 5.0.0 + * + */ +public class DoubleMidiFeedback extends Feedback { private static final int INIT_FEEDBACK_VALUE = 0; private int feedbackDefaultValue; // e.g. Color on an LaunchPad private int feedbackEventValue; // e.g. Color on an LaunchPad - public DoubleSimpleFeedback() { + public DoubleMidiFeedback() { this.feedbackDefaultValue = INIT_FEEDBACK_VALUE; this.feedbackEventValue = INIT_FEEDBACK_VALUE; } - public DoubleSimpleFeedback(int feedbackDefaultValue, int feedbackEventValue) { + public DoubleMidiFeedback(int feedbackDefaultValue, int feedbackEventValue) { this.feedbackDefaultValue = feedbackDefaultValue; this.feedbackEventValue = feedbackEventValue; } @@ -80,7 +91,7 @@ public class DoubleSimpleFeedback extends Feedback { @Override public Feedback cloneFeedback() throws CloneNotSupportedException { - DoubleSimpleFeedback feedback = (DoubleSimpleFeedback) super.clone(); + DoubleMidiFeedback feedback = (DoubleMidiFeedback) super.clone(); feedback.feedbackDefaultValue = feedbackDefaultValue; feedback.feedbackEventValue = feedbackEventValue; diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/SingleSimpleFeedback.java b/PlayWall/src/de/tobias/playpad/action/mapper/feedback/SingleMidiFeedback.java similarity index 73% rename from PlayWallCore/src/de/tobias/playpad/action/feedback/SingleSimpleFeedback.java rename to PlayWall/src/de/tobias/playpad/action/mapper/feedback/SingleMidiFeedback.java index 1981650351ebcd05ca07954dea7ba158e1a36de5..dfd37f546c945cdec28058292c4ad7f53c3688c6 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/SingleSimpleFeedback.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/feedback/SingleMidiFeedback.java @@ -1,18 +1,29 @@ -package de.tobias.playpad.action.feedback; +package de.tobias.playpad.action.mapper.feedback; import org.dom4j.Element; -public class SingleSimpleFeedback extends Feedback { +import de.tobias.playpad.action.feedback.Feedback; +import de.tobias.playpad.action.feedback.FeedbackMessage; + +/** + * Implementierung eines 1 State Feedbacks für MIDI Geräte. + * + * @author tobias + * + * @since 5.0.0 + * + */ +public class SingleMidiFeedback extends Feedback { private static final int INIT_FEEDBACK_VALUE = 0; private int feedbackValue; // e.g. Color on an LaunchPad - public SingleSimpleFeedback() { + public SingleMidiFeedback() { this.feedbackValue = INIT_FEEDBACK_VALUE; } - public SingleSimpleFeedback(int feedbackValue) { + public SingleMidiFeedback(int feedbackValue) { this.feedbackValue = feedbackValue; } @@ -63,7 +74,7 @@ public class SingleSimpleFeedback extends Feedback { @Override public Feedback cloneFeedback() throws CloneNotSupportedException { - SingleSimpleFeedback feedback = (SingleSimpleFeedback) super.clone(); + SingleMidiFeedback feedback = (SingleMidiFeedback) super.clone(); feedback.feedbackValue = feedbackValue; 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 953b862132bb4ab8fdd2d03dde4ccec0c31a2c33..000a86eb71df201c53943348ac2fd3109157a30c 100644 --- a/PlayWall/src/de/tobias/playpad/action/mapper/listener/KeyboardHandler.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/listener/KeyboardHandler.java @@ -9,6 +9,7 @@ import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; import javafx.event.EventHandler; +import javafx.scene.Scene; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; @@ -21,42 +22,44 @@ public class KeyboardHandler implements EventHandler<KeyEvent> { this.project = project; this.mainViewController = mainViewController; - mainViewController.getParent().getScene().setOnKeyPressed(this); - mainViewController.getParent().getScene().setOnKeyReleased(this); - mainViewController.getParent().getScene().setOnKeyTyped(this); + mainViewController.registerKeyboardListener(KeyEvent.ANY, this); } - private boolean[] keys = new boolean[KeyCode.values().length]; - + // KeyType ist nicht unterstützt. @Override public void handle(KeyEvent event) { - if (!event.isShortcutDown()) { - KeyCode code = null; - InputType type = null; + if (event.getTarget() instanceof Scene) { + if (!event.isShortcutDown()) { + KeyCode code = null; + InputType type = null; + + if (event.getEventType() == KeyEvent.KEY_PRESSED) { + code = event.getCode(); + type = InputType.PRESSED; - if (event.getEventType() == KeyEvent.KEY_PRESSED) { - code = event.getCode(); - type = InputType.PRESSED; + } else if (event.getEventType() == KeyEvent.KEY_RELEASED) { + code = event.getCode(); + type = InputType.RELEASED; - if (keys[code.ordinal()] == true) { - return; } - keys[code.ordinal()] = true; - } else if (event.getEventType() == KeyEvent.KEY_RELEASED) { - code = event.getCode(); - type = InputType.RELEASED; + // Only execute this, then the right event is triggered and this var is set + if (code != null) { + List<Action> actions = MappingUtils.getActionsForKey(code, Profile.currentProfile().getMappings().getActiveMapping()); - keys[code.ordinal()] = false; + executeActions(type, actions); + } } + } + } - // Only execute this, then the right event is triggered and this var is set - if (code != null) { - List<Action> actions = MappingUtils.getActionsForKey(code, Profile.currentProfile().getMappings().getActiveMapping()); - - for (Action action : actions) { - action.performAction(type, project, mainViewController); - } + private void executeActions(InputType type, List<Action> actions) { + for (Action action : actions) { + try { + action.performAction(type, project, mainViewController); + } catch (Exception e) { + e.printStackTrace(); + // TODO Exception Hadling } } } diff --git a/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandler.java b/PlayWall/src/de/tobias/playpad/audio/ClipAudioHandler.java index bc65aaeac79b714db9563ce171433ea73954d8ff..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,6 +35,7 @@ import javazoom.jl.decoder.JavaLayerException; public class ClipAudioHandler extends AudioHandler { + public static final String TYPE = "clip"; public static final String NAME = "Clip (Experimental)"; private static final String MP3 = "mp3"; @@ -68,7 +70,7 @@ public class ClipAudioHandler extends AudioHandler { if (handler.clip != null) { if (handler.clip.getMicrosecondLength() == handler.clip.getMicrosecondPosition() || !handler.pause || handler.stop) { - if (!pad.isLoop()) { + if (!pad.getPadSettings().isLoop()) { pad.setEof(true); // Remove from Loop and Stop @@ -83,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(); } } @@ -106,7 +110,7 @@ public class ClipAudioHandler extends AudioHandler { } stop = false; - if (getContent().getPad().isLoop()) + if (getContent().getPad().getPadSettings().isLoop()) clip.loop(Clip.LOOP_CONTINUOUSLY); // Loop else clip.start(); // Einfach Play @@ -207,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 cb6ba352622e388544baaa4d7df1c2c219a2276d..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,10 +91,9 @@ public class JavaFXAudioHandler extends AudioHandler implements Equalizable { @Override public void loadMedia(Path[] paths) { - Platform.runLater(() -> - { + Platform.runLater(() -> { if (getContent().getPad().isPadVisible()) { - getContent().getPad().getController().getParent().setBusy(true); + getContent().getPad().getController().getView().showBusyView(true); } }); @@ -107,34 +107,29 @@ 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().getParent().setBusy(false); + getContent().getPad().getController().getView().showBusyView(false); } }); }); - player.setOnError(() -> - { - Platform.runLater(() -> - { + player.setOnError(() -> { + Platform.runLater(() -> { if (getContent().getPad().isPadVisible()) { - getContent().getPad().getController().getParent().setBusy(false); + getContent().getPad().getController().getView().showBusyView(false); } }); loadedProperty.set(false); getContent().getPad().throwException(path, player.getError()); }); - player.setOnEndOfMedia(() -> - { - if (!getContent().getPad().isLoop()) { + player.setOnEndOfMedia(() -> { + if (!getContent().getPad().getPadSettings().isLoop()) { getContent().getPad().setEof(true); getContent().getPad().setStatus(PadStatus.STOP); } else { @@ -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 a995f7d0b871a5b150ad3d3f940bb6d794e18af7..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; @@ -66,7 +70,7 @@ public class TinyAudioHandler extends AudioHandler { if (handler.music != null) { if (!handler.music.playing()) { - if (!pad.isLoop()) { + if (!pad.getPadSettings().isLoop()) { pad.setEof(true); // Remove from Loop and Stop @@ -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(); } } @@ -126,7 +132,7 @@ public class TinyAudioHandler extends AudioHandler { public void play() { if (music != null) { if (!pause) { - if (!getContent().getPad().isLoop()) { + if (!getContent().getPad().getPadSettings().isLoop()) { music.play(false); // Kein Loop } else { music.play(true); // Mit Loop @@ -214,7 +220,7 @@ public class TinyAudioHandler extends AudioHandler { Platform.runLater(() -> { if (getContent().getPad().isPadVisible()) { - getContent().getPad().getController().getParent().setBusy(true); + getContent().getPad().getController().getView().showBusyView(true); } }); @@ -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()); } @@ -247,7 +254,7 @@ public class TinyAudioHandler extends AudioHandler { Platform.runLater(() -> { if (getContent().getPad().isPadVisible()) { - getContent().getPad().getController().getParent().setBusy(false); + getContent().getPad().getController().getView().showBusyView(false); } }); } 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/Actions.xml b/PlayWall/src/de/tobias/playpad/components/Actions.xml new file mode 100644 index 0000000000000000000000000000000000000000..f35a84f150b73b9f342010fd489c87b06e54c1c8 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/Actions.xml @@ -0,0 +1,5 @@ +<Actions> + <Component id="CART">de.tobias.playpad.action.connect.CartActionConnect</Component> + <Component id="PAGE">de.tobias.playpad.action.connect.PageActionConnect</Component> + <Component id="NAVIGATE">de.tobias.playpad.action.connect.NavigateActionConnect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/components/AudioHandler.xml b/PlayWall/src/de/tobias/playpad/components/AudioHandler.xml new file mode 100644 index 0000000000000000000000000000000000000000..f217977524027c6ea86e2d752a2bcc54852390a3 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/AudioHandler.xml @@ -0,0 +1,5 @@ +<Actions> + <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/components/Design.xml b/PlayWall/src/de/tobias/playpad/components/Design.xml new file mode 100644 index 0000000000000000000000000000000000000000..0e8188e17752e3889f820bc8f0804dd9aebadb6f --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/Design.xml @@ -0,0 +1,4 @@ +<Actions> + <Component id="modern" default="true">de.tobias.playpad.design.modern.ModernDesignConnect</Component> + <Component id="classic">de.tobias.playpad.design.classic.ClassicDesignConnect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/components/DragMode.xml b/PlayWall/src/de/tobias/playpad/components/DragMode.xml new file mode 100644 index 0000000000000000000000000000000000000000..11359ce78858ad76de75fe09e03e4c74ff9c78af --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/DragMode.xml @@ -0,0 +1,4 @@ +<Actions> + <Component id="move">de.tobias.playpad.pad.drag.MoveDragMode</Component> + <Component id="replace">de.tobias.playpad.pad.drag.ReplaceDragMode</Component> +</Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/components/Keys.xml b/PlayWall/src/de/tobias/playpad/components/Keys.xml new file mode 100644 index 0000000000000000000000000000000000000000..d5f0239e01f66870f30a2311003816151f3532af --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/Keys.xml @@ -0,0 +1,37 @@ + +<Keys> + <Windows> + <Key id="new_proj" name="main.menuitem.new" key="N" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="open_proj" name="main.menuitem.project" key="O" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="save_proj" name="main.menuitem.save" key="S" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="print_proj" name="main.menuitem.print" key="P" ctrl="true" alt="false" meta="false" shift="false"/> + + <Key id="dnd" name="main.menuitem.dnd" key="M" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="errors" name="main.menuitem.errors" key="E" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="plugins" name="main.menuitem.plugins"/> + <Key id="project_settings" name="main.menuitem.projectSettings" key="Comma" ctrl="true" alt="true" meta="false" shift="false"/> + <Key id="profile_settings" name="main.menuitem.profileSettings" key="Comma" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="global_settings" name="main.menuitem.globalSettings" key="Comma" ctrl="true" alt="false" meta="false" shift="true"/> + + <Key id="window_top" name="main.menuitem.onTop"/> + <Key id="window_fullscreen" name="main.menuitem.fullScreen" key="F" ctrl="true" alt="false" meta="false" shift="true"/> + <Key id="search_pad" name="main.menuitem.searchPad" key="F" ctrl="true" alt="false" meta="false" shift="false"/> + </Windows> + <Mac> + <Key id="new_proj" name="main.menuitem.new" key="N" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="open_proj" name="main.menuitem.project" key="O" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="save_proj" name="main.menuitem.save" key="S" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="print_proj" name="main.menuitem.print" key="P" ctrl="false" alt="false" meta="true" shift="false"/> + + <Key id="dnd" name="main.menuitem.dnd" key="M" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="errors" name="main.menuitem.errors" key="E" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="plugins" name="main.menuitem.plugins"/> + <Key id="project_settings" name="main.menuitem.projectSettings" key="Comma" ctrl="false" alt="true" meta="true" shift="false"/> + <Key id="profile_settings" name="main.menuitem.profileSettings" key="Comma" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="global_settings" name="main.menuitem.globalSettings" key="Comma" ctrl="false" alt="false" meta="true" shift="true"/> + + <Key id="window_top" name="main.menuitem.onTop"/> + <Key id="window_fullscreen" name="main.menuitem.fullScreen" key="F" ctrl="false" alt="false" meta="true" shift="true"/> + <Key id="search_pad" name="main.menuitem.searchPad" key="F" ctrl="false" alt="false" meta="true" shift="false"/> + </Mac> +</Keys> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/components/Layout.xml b/PlayWall/src/de/tobias/playpad/components/Layout.xml new file mode 100644 index 0000000000000000000000000000000000000000..a828ab59a3c21cb03d30f9c95f42ee754b5ff0e3 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/Layout.xml @@ -0,0 +1,4 @@ +<Actions> + <Component id="Desktop" default="true">de.tobias.playpad.layout.desktop.DesktopMainLayoutConnect</Component> + <Component id="Touch">de.tobias.playpad.layout.touch.TouchMainLayoutConnect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/components/Mapper.xml b/PlayWall/src/de/tobias/playpad/components/Mapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..9e0a14811feb8d3685b1c4ac6f3bfcc4e7b630c0 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/Mapper.xml @@ -0,0 +1,4 @@ +<Actions> + <Component id="MIDI">de.tobias.playpad.action.mapper.MidiMapperConnect</Component> + <Component id="KEYBOARD">de.tobias.playpad.action.mapper.KeyboardMapperConnect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/components/PadContent.xml b/PlayWall/src/de/tobias/playpad/components/PadContent.xml new file mode 100644 index 0000000000000000000000000000000000000000..43cfee85756a26829416ccb4b0122a5fb982b9bf --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/PadContent.xml @@ -0,0 +1,3 @@ +<Actions> + <Component id="audio">de.tobias.playpad.pad.content.AudioContentConnect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/components/Trigger.xml b/PlayWall/src/de/tobias/playpad/components/Trigger.xml new file mode 100644 index 0000000000000000000000000000000000000000..2b5b149507c381b952aa088bc722fea183c5c093 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/components/Trigger.xml @@ -0,0 +1,4 @@ +<Actions> + <Component id="Cart">de.tobias.playpad.trigger.CartTriggerItemConnect</Component> + <Component id="Volume">de.tobias.playpad.trigger.VolumeTriggerItemConnect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/layout/classic/ClassicCartLayout.java b/PlayWall/src/de/tobias/playpad/design/classic/ClassicCartDesign.java similarity index 91% rename from PlayWall/src/de/tobias/playpad/layout/classic/ClassicCartLayout.java rename to PlayWall/src/de/tobias/playpad/design/classic/ClassicCartDesign.java index 0e6d1952c35ea8cc7f3c8ad22c9ee122b1ffd996..af5a1e1ff864e345625432827a6911c7b0c3a7bd 100644 --- a/PlayWall/src/de/tobias/playpad/layout/classic/ClassicCartLayout.java +++ b/PlayWall/src/de/tobias/playpad/design/classic/ClassicCartDesign.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.layout.classic; +package de.tobias.playpad.design.classic; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -12,17 +12,17 @@ import org.dom4j.io.OutputFormat; import org.dom4j.io.XMLWriter; import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.Layout; -import de.tobias.playpad.pad.view.IPadViewController; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.Design; +import de.tobias.playpad.design.GlobalDesign; +import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Warning; -import de.tobias.playpad.viewcontroller.IPadView; import de.tobias.utils.util.ColorXMLUtils; import javafx.application.Platform; import javafx.scene.paint.Color; -public class ClassicCartLayout extends Layout implements CartLayout { +public class ClassicCartDesign extends Design implements CartDesign { public static final String TYPE = "classic"; @@ -145,8 +145,8 @@ public class ClassicCartLayout extends Layout implements CartLayout { } @Override - public CartLayout clone() throws CloneNotSupportedException { - ClassicCartLayout layout = (ClassicCartLayout) super.clone(); + public CartDesign clone() throws CloneNotSupportedException { + ClassicCartDesign layout = (ClassicCartDesign) super.clone(); layout.backgroundColor = Color.color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), backgroundColor.getOpacity()); @@ -210,8 +210,8 @@ public class ClassicCartLayout extends Layout implements CartLayout { } @Override - public void handleWarning(IPadViewController controller, Warning warning, GlobalLayout layout) { - final IPadView view = controller.getParent(); + public void handleWarning(IPadViewController controller, Warning warning, GlobalDesign layout) { + final IPadView view = controller.getView(); try { while (true) { @@ -238,9 +238,9 @@ public class ClassicCartLayout extends Layout implements CartLayout { } @Override - public void copyGlobalLayout(GlobalLayout globalLayout) { - if (globalLayout instanceof ClassicGlobalLayout) { - ClassicGlobalLayout classicGlobalLayout = (ClassicGlobalLayout) globalLayout; + public void copyGlobalLayout(GlobalDesign globalLayout) { + if (globalLayout instanceof ClassicGlobalDesign) { + ClassicGlobalDesign classicGlobalLayout = (ClassicGlobalDesign) globalLayout; backgroundColor = classicGlobalLayout.getBackgroundColor(); playbackColor = classicGlobalLayout.getPlaybackColor(); warnColor = classicGlobalLayout.getWarnColor(); diff --git a/PlayWall/src/de/tobias/playpad/design/classic/ClassicDesignConnect.java b/PlayWall/src/de/tobias/playpad/design/classic/ClassicDesignConnect.java new file mode 100644 index 0000000000000000000000000000000000000000..d4c0a91cbe2b3566b71d04389a68ad13a0daef45 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/design/classic/ClassicDesignConnect.java @@ -0,0 +1,49 @@ +package de.tobias.playpad.design.classic; + +import de.tobias.playpad.Strings; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.GlobalDesign; +import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.viewcontroller.CartDesignViewController; +import de.tobias.playpad.viewcontroller.GlobalDesignViewController; +import de.tobias.playpad.viewcontroller.design.ClassicCartDesignViewController; +import de.tobias.playpad.viewcontroller.design.ClassicGlobalDesignViewController; +import de.tobias.utils.util.Localization; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +public class ClassicDesignConnect extends DesignConnect { + + private static final String TYPE = "classic"; + + @Override + public StringProperty displayProperty() { + return new SimpleStringProperty(Localization.getString(Strings.Layout_Classic_Name)); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + public CartDesign newCartDesign() { + return new ClassicCartDesign(); + } + + @Override + public GlobalDesign newGlobalDesign() { + return new ClassicGlobalDesign(); + } + + @Override + public CartDesignViewController getCartDesignViewController(CartDesign cartLayout) { + return new ClassicCartDesignViewController(cartLayout); + } + + @Override + public GlobalDesignViewController getGlobalDesignViewController(GlobalDesign globalLayout) { + return new ClassicGlobalDesignViewController(globalLayout); + } + +} diff --git a/PlayWall/src/de/tobias/playpad/layout/classic/ClassicGlobalLayout.java b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java similarity index 93% rename from PlayWall/src/de/tobias/playpad/layout/classic/ClassicGlobalLayout.java rename to PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java index 2f067be0999ac96553b147d75bde2c479098014b..e317fc50cd6c4398292a962305ef26245ed71344 100644 --- a/PlayWall/src/de/tobias/playpad/layout/classic/ClassicGlobalLayout.java +++ b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.layout.classic; +package de.tobias.playpad.design.classic; import java.io.IOException; import java.nio.file.Files; @@ -7,14 +7,15 @@ import java.nio.file.Path; import org.dom4j.Element; import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.Layout; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.Design; +import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.view.IPadViewController; +import de.tobias.playpad.pad.PadSettings; +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.IPadView; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; @@ -25,7 +26,7 @@ import javafx.beans.property.SimpleObjectProperty; import javafx.scene.paint.Color; import javafx.stage.Stage; -public class ClassicGlobalLayout extends Layout implements GlobalLayout { +public class ClassicGlobalDesign extends Design implements GlobalDesign { public static final double minWidth = 180; public static final double minHeight = 100; @@ -230,8 +231,8 @@ public class ClassicGlobalLayout extends Layout implements GlobalLayout { } @Override - public GlobalLayout clone() throws CloneNotSupportedException { - ClassicGlobalLayout layout = (ClassicGlobalLayout) super.clone(); + public GlobalDesign clone() throws CloneNotSupportedException { + ClassicGlobalDesign layout = (ClassicGlobalDesign) super.clone(); layout.backgroundColor = Color.color(backgroundColor.getRed(), backgroundColor.getGreen(), backgroundColor.getBlue(), backgroundColor.getOpacity()); @@ -299,9 +300,6 @@ public class ClassicGlobalLayout extends Layout implements GlobalLayout { @Override public void applyCss(Stage stage) { - // Clear Old - stage.getScene().getStylesheets().clear(); - // Add Build in Default stage.getScene().getStylesheets().add("de/tobias/playpad/assets/style.css"); stage.getScene().getStylesheets().add("de/tobias/playpad/assets/classic_style.css"); @@ -327,8 +325,10 @@ public class ClassicGlobalLayout extends Layout implements GlobalLayout { // Pad Spezelles Layout immer for (Pad pad : project.getPads().values()) { - if (pad.isCustomLayout()) { - CartLayout layoutOpt = pad.getLayout(); + PadSettings padSettings = pad.getPadSettings(); + + if (padSettings.isCustomLayout()) { + CartDesign layoutOpt = padSettings.getLayout(); css += "\n" + layoutOpt.convertToCss(String.valueOf(pad.getIndex()), true); } } @@ -346,7 +346,7 @@ public class ClassicGlobalLayout extends Layout implements GlobalLayout { @Override public void handleWarning(IPadViewController controller, Warning warning) { - final IPadView view = controller.getParent(); + final IPadView view = controller.getView(); try { while (true) { diff --git a/PlayWall/src/de/tobias/playpad/layout/classic/Theme.java b/PlayWall/src/de/tobias/playpad/design/classic/Theme.java similarity index 94% rename from PlayWall/src/de/tobias/playpad/layout/classic/Theme.java rename to PlayWall/src/de/tobias/playpad/design/classic/Theme.java index 4405ffb716d1456eb44b7eab7970664a05864c49..ece02aba8229b6defe6211ff9de182c51ded134b 100644 --- a/PlayWall/src/de/tobias/playpad/layout/classic/Theme.java +++ b/PlayWall/src/de/tobias/playpad/design/classic/Theme.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.layout.classic; +package de.tobias.playpad.design.classic; import javafx.scene.paint.Color; diff --git a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutCart.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java similarity index 82% rename from PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutCart.java rename to PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java index 123f41277e3ab741e7744047d36bddb17b92af9e..86fde0806c5beead2460a7394eddb8a40ccc9d97 100644 --- a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutCart.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java @@ -1,21 +1,21 @@ -package de.tobias.playpad.layout.modern; +package de.tobias.playpad.design.modern; import org.dom4j.Element; import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.FadeableColor; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.Layout; -import de.tobias.playpad.layout.LayoutColorAssociator; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.Design; +import de.tobias.playpad.design.DesignColorAssociator; +import de.tobias.playpad.design.FadeableColor; +import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.conntent.Durationable; -import de.tobias.playpad.pad.view.IPadViewController; +import de.tobias.playpad.pad.conntent.play.Durationable; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Warning; import javafx.scene.paint.Color; import javafx.util.Duration; -public class ModernLayoutCart extends Layout implements CartLayout, LayoutColorAssociator { +public class ModernCartDesign extends Design implements CartDesign, DesignColorAssociator { public static final String TYPE = "modern"; @@ -75,17 +75,17 @@ public class ModernLayoutCart extends Layout implements CartLayout, LayoutColorA // Warn Handler -> Animation oder Blinken @Override - public void handleWarning(IPadViewController controller, Warning warning, GlobalLayout layout) { - if (layout instanceof ModernLayoutGlobal && ((ModernLayoutGlobal) layout).isWarnAnimation()) { + public void handleWarning(IPadViewController controller, Warning warning, GlobalDesign layout) { + if (layout instanceof ModernGlobalDesign && ((ModernGlobalDesign) layout).isWarnAnimation()) { warnAnimation(controller, warning); } else { - ModernLayoutAnimator.warnFlash(controller); + ModernDesignAnimator.warnFlash(controller); } } @Override public void stopWarning(IPadViewController controller) { - ModernLayoutAnimator.stopAnimation(controller); + ModernDesignAnimator.stopAnimation(controller); } private void warnAnimation(IPadViewController controller, Warning warning) { @@ -96,12 +96,13 @@ public class ModernLayoutCart extends Layout implements CartLayout, LayoutColorA Pad pad = controller.getPad(); if (pad.getContent() instanceof Durationable) { - if (warnDuration.greaterThan(((Durationable) pad.getContent()).getDuration())) { - warnDuration = ((Durationable) pad.getContent()).getDuration(); + Duration padDuration = ((Durationable) pad.getContent()).getDuration(); + if (warnDuration.greaterThan(padDuration)) { + warnDuration = padDuration; } } - ModernLayoutAnimator.animateWarn(controller, playColor, stopColor, warnDuration); + ModernDesignAnimator.animateWarn(controller, playColor, stopColor, warnDuration); } // Cart Layout @@ -177,9 +178,9 @@ public class ModernLayoutCart extends Layout implements CartLayout, LayoutColorA } @Override - public void copyGlobalLayout(GlobalLayout globalLayout) { - if (globalLayout instanceof ModernLayoutGlobal) { - ModernLayoutGlobal modernLayoutGlobal = (ModernLayoutGlobal) globalLayout; + public void copyGlobalLayout(GlobalDesign globalLayout) { + if (globalLayout instanceof ModernGlobalDesign) { + ModernGlobalDesign modernLayoutGlobal = (ModernGlobalDesign) globalLayout; backgroundColor = modernLayoutGlobal.getBackgroundColor(); playColor = modernLayoutGlobal.getPlayColor(); } diff --git a/PlayWall/src/de/tobias/playpad/layout/modern/ModernColor.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernColor.java similarity index 99% rename from PlayWall/src/de/tobias/playpad/layout/modern/ModernColor.java rename to PlayWall/src/de/tobias/playpad/design/modern/ModernColor.java index 7e94e20e47a289072a6e8c0856f6370d35a798ea..9bd1a139283a9eaa857b55cc361e98a486c75f32 100644 --- a/PlayWall/src/de/tobias/playpad/layout/modern/ModernColor.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernColor.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.layout.modern; +package de.tobias.playpad.design.modern; import de.tobias.playpad.DisplayableColor; import javafx.scene.paint.Color; diff --git a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutAnimator.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignAnimator.java similarity index 86% rename from PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutAnimator.java rename to PlayWall/src/de/tobias/playpad/design/modern/ModernDesignAnimator.java index e8fd950c69c7eedee044131e901a02c2266cef73..4d63d00aa52f650374858cd7debe77d3a8922612 100644 --- a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutAnimator.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignAnimator.java @@ -1,11 +1,11 @@ -package de.tobias.playpad.layout.modern; +package de.tobias.playpad.design.modern; import java.util.HashMap; import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.layout.FadeableColor; -import de.tobias.playpad.pad.view.IPadViewController; -import de.tobias.playpad.viewcontroller.IPadView; +import de.tobias.playpad.design.FadeableColor; +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; @@ -16,10 +16,10 @@ import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.util.Duration; -public class ModernLayoutAnimator { +public class ModernDesignAnimator { // alles nur static, neine objecte von der Klasse - private ModernLayoutAnimator() {} + private ModernDesignAnimator() {} private static HashMap<Integer, Timeline> timelines = new HashMap<>(); @@ -34,7 +34,7 @@ public class ModernLayoutAnimator { @Override public void changed(ObservableValue<? extends FadeableColor> observable, FadeableColor oldValue, FadeableColor newValue) { - padViewController.getParent().setStyle("-fx-background-color: " + newValue.toString() + ";"); + padViewController.getView().setStyle("-fx-background-color: " + newValue.toString() + ";"); } }; @@ -48,7 +48,7 @@ public class ModernLayoutAnimator { timeline.setOnFinished(event -> { backgroundColor.removeListener(fadeListener); - padViewController.getParent().setStyle(""); + padViewController.getView().setStyle(""); timelines.remove(index); }); @@ -68,7 +68,7 @@ public class ModernLayoutAnimator { @Override public void changed(ObservableValue<? extends FadeableColor> observable, FadeableColor oldValue, FadeableColor newValue) { - padViewController.getParent().setStyle("-fx-background-color: " + newValue.toString() + ";"); + padViewController.getView().setStyle("-fx-background-color: " + newValue.toString() + ";"); } }; @@ -87,7 +87,7 @@ public class ModernLayoutAnimator { timeline.setOnFinished(event -> { backgroundColor.removeListener(fadeListener); - padViewController.getParent().setStyle(""); + padViewController.getView().setStyle(""); timelines.remove(index); }); @@ -104,7 +104,7 @@ public class ModernLayoutAnimator { } public static void warnFlash(IPadViewController controller) { - final IPadView view = controller.getParent(); + final IPadView view = controller.getView(); try { while (true) { Platform.runLater(() -> diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignConnect.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignConnect.java new file mode 100644 index 0000000000000000000000000000000000000000..4658e1a66596a0a05648a6817a84190f544861fd --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignConnect.java @@ -0,0 +1,49 @@ +package de.tobias.playpad.design.modern; + +import de.tobias.playpad.Strings; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.GlobalDesign; +import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.viewcontroller.CartDesignViewController; +import de.tobias.playpad.viewcontroller.GlobalDesignViewController; +import de.tobias.playpad.viewcontroller.design.ModernCartDesignViewController; +import de.tobias.playpad.viewcontroller.design.ModernGlobalDesignViewController; +import de.tobias.utils.util.Localization; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; + +public class ModernDesignConnect extends DesignConnect { + + private static final String TYPE = "modern"; + + @Override + public StringProperty displayProperty() { + return new SimpleStringProperty(Localization.getString(Strings.Layout_Modern_Name)); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + public CartDesign newCartDesign() { + return new ModernCartDesign(); + } + + @Override + public GlobalDesign newGlobalDesign() { + return new ModernGlobalDesign(); + } + + @Override + public CartDesignViewController getCartDesignViewController(CartDesign cartLayout) { + return new ModernCartDesignViewController(cartLayout); + } + + @Override + public GlobalDesignViewController getGlobalDesignViewController(GlobalDesign globalLayout) { + return new ModernGlobalDesignViewController(globalLayout); + } + +} diff --git a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutGlobal.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java similarity index 90% rename from PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutGlobal.java rename to PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java index c8e79942e2a50cc747ce271d5a55ce805186cf45..8a1903ab15afc82900c77eb0bca03a8d6c57f9b3 100644 --- a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutGlobal.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.layout.modern; +package de.tobias.playpad.design.modern; import java.io.IOException; import java.nio.file.Files; @@ -7,14 +7,15 @@ import java.nio.file.Path; import org.dom4j.Element; import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.FadeableColor; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.Layout; -import de.tobias.playpad.layout.LayoutColorAssociator; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.Design; +import de.tobias.playpad.design.DesignColorAssociator; +import de.tobias.playpad.design.FadeableColor; +import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.conntent.Durationable; -import de.tobias.playpad.pad.view.IPadViewController; +import de.tobias.playpad.pad.PadSettings; +import de.tobias.playpad.pad.conntent.play.Durationable; +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; @@ -25,12 +26,12 @@ import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.util.Duration; -public class ModernLayoutGlobal extends Layout implements GlobalLayout, LayoutColorAssociator { +public class ModernGlobalDesign extends Design implements GlobalDesign, DesignColorAssociator { 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; @@ -105,7 +106,7 @@ public class ModernLayoutGlobal extends Layout implements GlobalLayout, LayoutCo playColor = ModernColor.RED1; isWarnAnimation = true; - + infoFontSize = 14; titleFontSize = 16; } @@ -173,9 +174,6 @@ public class ModernLayoutGlobal extends Layout implements GlobalLayout, LayoutCo @Override public void applyCss(Stage stage) { - // Clear Old - stage.getScene().getStylesheets().clear(); - // Add Build in Default stage.getScene().getStylesheets().add("de/tobias/playpad/assets/style.css"); stage.getScene().getStylesheets().add("de/tobias/playpad/assets/modern_style.css"); @@ -198,8 +196,10 @@ public class ModernLayoutGlobal extends Layout implements GlobalLayout, LayoutCo // Pad Spezelles Layout immer for (Pad pad : project.getPads().values()) { - if (pad.isCustomLayout()) { - CartLayout layoutOpt = pad.getLayout(Profile.currentProfile().getProfileSettings().getLayoutType()); + PadSettings padSettings = pad.getPadSettings(); + + if (padSettings.isCustomLayout()) { + CartDesign layoutOpt = padSettings.getLayout(Profile.currentProfile().getProfileSettings().getLayoutType()); css += "\n" + layoutOpt.convertToCss(String.valueOf(pad.getIndex()), true); } } @@ -278,13 +278,13 @@ public class ModernLayoutGlobal extends Layout implements GlobalLayout, LayoutCo if (isWarnAnimation) { warnAnimation(controller, warning); } else { - ModernLayoutAnimator.warnFlash(controller); + ModernDesignAnimator.warnFlash(controller); } } @Override public void stopWarning(IPadViewController controller) { - ModernLayoutAnimator.stopAnimation(controller); + ModernDesignAnimator.stopAnimation(controller); } private void warnAnimation(IPadViewController controller, Warning warning) { @@ -300,7 +300,7 @@ public class ModernLayoutGlobal extends Layout implements GlobalLayout, LayoutCo } } - ModernLayoutAnimator.animateWarn(controller, playColor, stopColor, warnDuration); + ModernDesignAnimator.animateWarn(controller, playColor, stopColor, warnDuration); } // Color Associator diff --git a/PlayWall/src/de/tobias/playpad/layout/classic/ClassicLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/classic/ClassicLayoutConnect.java deleted file mode 100644 index bab85710670ae3f9ddc79b6bd7392721f15c0b1b..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/layout/classic/ClassicLayoutConnect.java +++ /dev/null @@ -1,49 +0,0 @@ -package de.tobias.playpad.layout.classic; - -import de.tobias.playpad.Strings; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.LayoutConnect; -import de.tobias.playpad.viewcontroller.CartLayoutViewController; -import de.tobias.playpad.viewcontroller.GlobalLayoutViewController; -import de.tobias.playpad.viewcontroller.layout.ClassicLayoutCartViewController; -import de.tobias.playpad.viewcontroller.layout.ClassicLayoutGlobalViewController; -import de.tobias.utils.util.Localization; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; - -public class ClassicLayoutConnect extends LayoutConnect { - - private static final String TYPE = "classic"; - - @Override - public StringProperty displayProperty() { - return new SimpleStringProperty(Localization.getString(Strings.Layout_Classic_Name)); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - public CartLayout newCartLayout() { - return new ClassicCartLayout(); - } - - @Override - public GlobalLayout newGlobalLayout() { - return new ClassicGlobalLayout(); - } - - @Override - public CartLayoutViewController getCartLayoutViewController(CartLayout cartLayout) { - return new ClassicLayoutCartViewController(cartLayout); - } - - @Override - public GlobalLayoutViewController getGlobalLayoutViewController(GlobalLayout globalLayout) { - return new ClassicLayoutGlobalViewController(globalLayout); - } - -} diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java new file mode 100644 index 0000000000000000000000000000000000000000..9d9b3657b2436e236cf07934870d735adbc84ee4 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java @@ -0,0 +1,67 @@ +package de.tobias.playpad.layout.desktop; + +import java.util.Stack; + +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<IPadView> recyclingStack; + + public DesktopMainLayoutConnect() { + recyclingStack = new Stack<>(); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + public String name() { + return Localization.getString(Strings.MainLayout_Desktop); + } + + @Override + public MenuToolbarViewController createMenuToolbar(IMainViewController mainViewRef) { + if (desktopMenuToolbarViewController == null) { + desktopMenuToolbarViewController = new DesktopMenuToolbarViewController(mainViewRef); + } + return desktopMenuToolbarViewController; + } + + @Override + public IPadView createPadView() { + if (!recyclingStack.isEmpty()) { + return recyclingStack.pop(); + } + return new DesktopPadView(); + } + + @Override + public void recyclePadView(IPadView padView) { + recyclingStack.push(padView); + } + + @Override + public String getStylesheet() { + return null; + } + +} diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..6fe5003cf5241fdb29778da90997145b657d2ab7 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -0,0 +1,634 @@ +package de.tobias.playpad.layout.desktop; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import org.controlsfx.control.textfield.TextFields; + +import de.tobias.playpad.AppUserInfoStrings; +import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; +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.IPadView; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectNotFoundException; +import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.registry.Registry; +import de.tobias.playpad.settings.GlobalSettings; +import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileNotFoundException; +import de.tobias.playpad.settings.ProfileSettings; +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; +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.main.BasicMenuToolbarViewController; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.global.GlobalSettingsViewController; +import de.tobias.playpad.viewcontroller.option.profile.ProfileSettingsViewController; +import de.tobias.playpad.viewcontroller.option.project.ProjectSettingsViewController; +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.ui.Alertable; +import de.tobias.utils.ui.scene.NotificationPane; +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; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.Button; +import javafx.scene.control.CheckMenuItem; +import javafx.scene.control.Label; +import javafx.scene.control.Menu; +import javafx.scene.control.MenuBar; +import javafx.scene.control.MenuItem; +import javafx.scene.control.Slider; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.HBox; +import javafx.stage.Modality; +import javafx.stage.Stage; + +public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewController implements EventHandler<ActionEvent> { + + // meuBar + @FXML protected MenuBar menuBar; + + @FXML protected MenuItem newProjectMenuItem; + @FXML protected MenuItem openProjectMenuItem; + @FXML protected MenuItem saveProjectMenuItem; + @FXML protected MenuItem profileMenu; + @FXML protected MenuItem printProjectMenuItem; + + @FXML protected CheckMenuItem dndModeMenuItem; + @FXML protected MenuItem errorMenu; + @FXML protected MenuItem pluginMenu; + + @FXML protected MenuItem projectSettingsMenuItem; + @FXML protected MenuItem profileSettingsMenuItem; + @FXML protected MenuItem globalSettingsMenuItem; + + @FXML protected CheckMenuItem fullScreenMenuItem; + @FXML protected CheckMenuItem alwaysOnTopItem; + @FXML protected MenuItem searchPadMenuItem; + + @FXML protected Menu layoutMenu; + + @FXML protected Menu extensionMenu; + @FXML protected Menu infoMenu; + @FXML protected Menu helpMenu; + + @FXML protected Label liveLabel; + + private IMainViewController mainViewController; + + private ProjectSettingsViewController projectSettingsViewController; + private ProfileSettingsViewController profileSettingsViewController; + private GlobalSettingsViewController globalSettingsViewController; + + public DesktopMenuToolbarViewController(IMainViewController controller) { + super("header", "de/tobias/playpad/assets/view/main/desktop/", PlayPadMain.getUiResourceBundle()); + this.mainViewController = controller; + + initLayoutMenu(); + } + + @Override + public void init() { + super.init(); + toolbarHBox.prefWidthProperty().bind(toolbar.widthProperty().subtract(25)); + toolbarHBox.prefHeightProperty().bind(toolbar.minHeightProperty()); + + // 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(); + + int index = 1; // Für Tastenkombination + for (MainLayoutConnect connect : mainLayouts.getComponents()) { + if (!connect.getType().equals(profileSettings.getMainLayoutType())) { + MenuItem item = new MenuItem(connect.name()); + + item.setOnAction(e -> + { + mainViewController.setMainLayout(connect); + Profile.currentProfile().getProfileSettings().setMainLayoutType(connect.getType()); + }); + + // Key Combi + if (index < 10) { + item.setAccelerator(KeyCombination.keyCombination("Shortcut+" + index)); + } + + layoutMenu.getItems().add(item); + index++; + } + } + } + + @Override + public void setOpenProject(Project project) { + super.setOpenProject(project); + + liveLabel.visibleProperty().unbind(); + + if (project != null) { + createRecentDocumentMenuItems(); + liveLabel.visibleProperty().bind(project.activePlayerProperty().greaterThan(0)); + } + } + + @Override + public void initPageButtons() { + pageHBox.getChildren().clear(); + + if (openProject == null) { + return; + } + + 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); + } + } + + @Override + public void loadKeybinding(KeyCollection keys) { + setKeyBindingForMenu(newProjectMenuItem, keys.getKey("new_proj")); + setKeyBindingForMenu(openProjectMenuItem, keys.getKey("open_proj")); + setKeyBindingForMenu(saveProjectMenuItem, keys.getKey("save_proj")); + setKeyBindingForMenu(printProjectMenuItem, keys.getKey("print_proj")); + + setKeyBindingForMenu(dndModeMenuItem, keys.getKey("dnd")); + setKeyBindingForMenu(errorMenu, keys.getKey("errors")); + setKeyBindingForMenu(pluginMenu, keys.getKey("plugins")); + setKeyBindingForMenu(projectSettingsMenuItem, keys.getKey("project_settings")); + setKeyBindingForMenu(profileSettingsMenuItem, keys.getKey("profile_settings")); + setKeyBindingForMenu(globalSettingsMenuItem, keys.getKey("global_settings")); + + setKeyBindingForMenu(fullScreenMenuItem, keys.getKey("window_fullscreen")); + setKeyBindingForMenu(alwaysOnTopItem, keys.getKey("window_top")); + setKeyBindingForMenu(searchPadMenuItem, keys.getKey("search_pad")); + + newProjectMenuItem.setDisable(false); + openProjectMenuItem.setDisable(false); + saveProjectMenuItem.setDisable(false); + printProjectMenuItem.setDisable(false); + + dndModeMenuItem.setDisable(false); + errorMenu.setDisable(false); + pluginMenu.setDisable(false); + projectSettingsMenuItem.setDisable(false); + profileSettingsMenuItem.setDisable(false); + globalSettingsMenuItem.setDisable(false); + + fullScreenMenuItem.setDisable(false); + alwaysOnTopItem.setDisable(false); + searchPadMenuItem.setDisable(false); + } + + @Override + public void setLocked(boolean looked) { + dndModeMenuItem.setDisable(looked); + } + + @Override + public void setAlwaysOnTopActive(boolean alwaysOnTopActive) { + alwaysOnTopItem.setSelected(alwaysOnTopActive); + } + + @Override + public void setFullScreenActive(boolean fullScreenActive) { + fullScreenMenuItem.setSelected(fullScreenActive); + } + + @Override + public void addToolbarItem(Node node) { + iconHbox.getChildren().add(node); + } + + @Override + public void removeToolbarItem(Node node) { + iconHbox.getChildren().remove(node); + } + + @Override + public void addMenuItem(MenuItem item, MenuType type) { + if (type == MenuType.EXTENSION) { + extensionMenu.getItems().add(item); + } + } + + @Override + public void removeMenuItem(MenuItem item) { + if (extensionMenu.getItems().contains(item)) + extensionMenu.getItems().remove(item); + } + + @Override + public void deinit() { + newProjectMenuItem.setDisable(true); + openProjectMenuItem.setDisable(true); + saveProjectMenuItem.setDisable(true); + printProjectMenuItem.setDisable(true); + + dndModeMenuItem.setDisable(true); + errorMenu.setDisable(true); + pluginMenu.setDisable(true); + projectSettingsMenuItem.setDisable(true); + profileSettingsMenuItem.setDisable(true); + globalSettingsMenuItem.setDisable(true); + + fullScreenMenuItem.setDisable(true); + alwaysOnTopItem.setDisable(true); + searchPadMenuItem.setDisable(true); + + // Disable Drag Mode wenn aktiv und diese Toolbar deaktiviert wird. + if (dndModeMenuItem.isSelected()) { + PadDragListener.setDndMode(false); + for (IPadView view : mainViewController.getPadViews()) { + view.enableDragAndDropDesignMode(false); + } + } + } + + @Override + public Slider getVolumeSlider() { + return volumeSlider; + } + + private int currentPage = 0; + + @Override + public void highlightPageButton(int index) { + if (index >= 0) { + if (pageHBox.getChildren().size() > currentPage) { + Node removeNode = pageHBox.getChildren().get(currentPage); + removeNode.getStyleClass().remove(CURRENT_PAGE_BUTTON); + } + + if (pageHBox.getChildren().size() > index) { + Node newNode = pageHBox.getChildren().get(index); + newNode.getStyleClass().add(CURRENT_PAGE_BUTTON); + currentPage = index; + } + } + } + + // EventHandler + @FXML + void newDocumentHandler(ActionEvent event) { + doAction(() -> + { + NewProjectDialog dialog = new NewProjectDialog(mainViewController.getStage()); + dialog.getStage().showAndWait(); + + Project project = dialog.getProject(); + if (project != null) { + PlayPadMain.getProgramInstance().openProject(project); + } + }); + } + + @FXML + void openDocumentHandler(ActionEvent event) { + doAction(() -> + { + Stage stage = mainViewController.getStage(); + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + + ProjectManagerDialog view = new ProjectManagerDialog(stage, currentProject); + Optional<ProjectReference> result = view.showAndWait(); + + if (result.isPresent()) { + ProjectReference ref = result.get(); + + try { + Project project = Project.load(result.get(), true, ImportDialog.getInstance(stage)); + PlayPadMain.getProgramInstance().openProject(project); + + createRecentDocumentMenuItems(); + } catch (ProfileNotFoundException e) { + e.printStackTrace(); + + // Error Message + String errorMessage = Localization.getString(Strings.Error_Profile_NotFound, ref.getProfileReference(), + e.getLocalizedMessage()); + mainViewController.showError(errorMessage); + + // Neues Profile wählen + Profile profile = ImportDialog.getInstance(stage).getUnkownProfile(); + ref.setProfileReference(profile.getRef()); + } catch (ProjectNotFoundException e) { + e.printStackTrace(); + mainViewController.showError(Localization.getString(Strings.Error_Project_NotFound, ref, e.getLocalizedMessage())); + } catch (Exception e) { + e.printStackTrace(); + mainViewController.showError(Localization.getString(Strings.Error_Project_Open, ref, e.getLocalizedMessage())); + } + } + }); + } + + @FXML + void saveMenuHandler(ActionEvent event) { + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + + try { + currentProject.save(); + mainViewController.notify(Localization.getString(Strings.Standard_File_Save), PlayPadMain.displayTimeMillis); + } catch (IOException e) { + mainViewController.showError(Localization.getString(Strings.Error_Project_Save)); + e.printStackTrace(); + } + } + + @FXML + void profileMenuHandler(ActionEvent event) { + doAction(() -> + { + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + + ProfileViewController controller = new ProfileViewController(mainViewController.getStage(), currentProject); + controller.getStage().showAndWait(); + mainViewController.updateWindowTitle(); + }); + } + + @FXML + void printMenuHandler(ActionEvent event) { + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + PrintDialog dialog = new PrintDialog(currentProject, mainViewController.getStage()); + dialog.getStage().show(); + } + + @FXML + void dndModeHandler(ActionEvent event) { + if (dndModeMenuItem.isSelected()) { + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + + if (settings.isLiveMode() && settings.isLiveModeDrag() && currentProject.getActivePlayers() == 0) { + PadDragListener.setDndMode(true); + for (IPadView view : mainViewController.getPadViews()) { + view.enableDragAndDropDesignMode(true); + } + } + } else { + PadDragListener.setDndMode(false); + for (IPadView view : mainViewController.getPadViews()) { + view.enableDragAndDropDesignMode(false); + } + } + + } + + @FXML + void errorMenuHandler(ActionEvent event) { + ErrorSummaryDialog.getInstance().getStage().show(); + } + + @FXML + void pluginMenuItemHandler(ActionEvent event) { + doAction(() -> + { + PluginViewController controller = new PluginViewController(mainViewController.getStage()); + controller.getStage().showAndWait(); + }); + } + + @FXML + void projectSettingsHandler(ActionEvent event) { + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + + if (projectSettingsViewController == null) { + Stage mainStage = mainViewController.getStage(); + + Runnable onFinish = () -> + { + projectSettingsViewController = null; + mainStage.toFront(); + }; + + projectSettingsViewController = new ProjectSettingsViewController(mainViewController.getScreen(), mainStage, currentProject, + onFinish); + + projectSettingsViewController.getStage().show(); + } else if (projectSettingsViewController.getStage().isShowing()) { + projectSettingsViewController.getStage().toFront(); + } + } + + @FXML + void profileSettingsHandler(ActionEvent event) { + Midi midi = Midi.getInstance(); + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); + + if (settings.isLiveMode() && settings.isLiveModeSettings() && currentProject.getActivePlayers() > 0) { + return; + } + + if (profileSettingsViewController == null) { + Stage mainStage = mainViewController.getStage(); + + Runnable onFinish = () -> + { + midi.setListener(mainViewController.getMidiHandler()); + + profileSettingsViewController = null; + mainStage.toFront(); + }; + + profileSettingsViewController = new ProfileSettingsViewController(midi, mainViewController.getScreen(), mainStage, currentProject, + onFinish); + + profileSettingsViewController.getStage().show(); + } else if (profileSettingsViewController.getStage().isShowing()) { + profileSettingsViewController.getStage().toFront(); + } + } + + @FXML + void globalSettingsHandler(ActionEvent event) { + if (globalSettingsViewController == null) { + + Stage mainStage = mainViewController.getStage(); + Runnable onFinish = () -> + { + globalSettingsViewController = null; + mainStage.toFront(); + }; + + globalSettingsViewController = new GlobalSettingsViewController(mainStage, onFinish); + globalSettingsViewController.getStage().show(); + } else { + globalSettingsViewController.getStage().toFront(); + } + } + + @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 searchPadHandler(ActionEvent event) { + TextField field = TextFields.createClearableTextField(); + field.setPromptText(Localization.getString(Strings.Search_Placeholder)); + + Button button = new Button(Localization.getString(Strings.Search_Button)); + button.setOnAction(new DesktopSearchController(field, this)); + + HBox box = new HBox(14, field, button); + box.setAlignment(Pos.CENTER_LEFT); + + NotificationPane pane = mainViewController.getNotificationPane(); + pane.show("", box); + + // Auto Complete + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + Set<String> names = currentProject.getPads().values().stream().filter(p -> p.getStatus() != PadStatus.EMPTY).map(Pad::getName) + .collect(Collectors.toSet()); + TextFields.bindAutoCompletion(field, names); + } + + @FXML + void aboutMenuHandler(ActionEvent event) { + ApplicationInfo info = ApplicationUtils.getApplication().getInfo(); + String message = Localization.getString(Strings.UI_Dialog_Info_Content, info.getVersion(), info.getBuild(), info.getAuthor()); + if (mainViewController instanceof Alertable) { + ((Alertable) mainViewController).showInfoMessage(message, Localization.getString(Strings.UI_Dialog_Info_Header, info.getName()), + PlayPadMain.stageIcon.orElse(null)); + } + } + + @FXML + 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 + void sendErrorMenuItem(ActionEvent event) { + Alert alert = new Alert(AlertType.INFORMATION); + alert.initOwner(mainViewController.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(); + } + }); + } + + private final int LAST_DOCUMENT_LIMIT = 3; + + public void createRecentDocumentMenuItems() { + recentOpenMenu.getItems().clear(); + + String project = openProject.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); + }); + } + + @Override + public void handle(ActionEvent event) { + if (event.getSource() instanceof Button) { + Button button = (Button) event.getSource(); + int page = (int) button.getUserData(); + mainViewController.showPage(page); + } else if (event.getSource() instanceof MenuItem) { + // Zuletzt verwendete Projects + doAction(() -> + { + // TODO Rewrite mit openProject von BasicMenuToolbarViewController + 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(mainViewController.getStage())); + PlayPadMain.getProgramInstance().openProject(project); + } catch (ProfileNotFoundException e) { + e.printStackTrace(); + mainViewController.showError( + Localization.getString(Strings.Error_Profile_NotFound, ref.getProfileReference(), e.getLocalizedMessage())); + + // Neues Profile wählen + Profile profile = ImportDialog.getInstance(mainViewController.getStage()).getUnkownProfile(); + ref.setProfileReference(profile.getRef()); + } catch (ProjectNotFoundException e) { + e.printStackTrace(); + mainViewController.showError(Localization.getString(Strings.Error_Project_NotFound, ref, e.getLocalizedMessage())); + } catch (Exception e) { + e.printStackTrace(); + mainViewController.showError(Localization.getString(Strings.Error_Project_Open, ref, e.getLocalizedMessage())); + } + }); + } + } +} diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java new file mode 100644 index 0000000000000000000000000000000000000000..72d74d982d3b7465e7abe24e6b4c0a58774e56ea --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java @@ -0,0 +1,410 @@ +package de.tobias.playpad.layout.desktop; + +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.PseudoClasses; +import de.tobias.playpad.pad.Pad; +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.conntent.play.Pauseable; +import de.tobias.playpad.pad.view.IPadContentView; +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.ui.translation.PulseTranslation; +import javafx.beans.property.Property; +import javafx.css.PseudoClass; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ProgressBar; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.Region; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; + +public class DesktopPadView implements IPadView { + + private Label indexLabel; + private Label loopLabel; + private Label triggerLabel; + private Label errorLabel; + + private HBox infoBox; + private Label timeLabel; + + private HBox preview; + private IPadContentView previewContent; + + private ProgressBar playBar; + private Button playButton; + private Button pauseButton; + private Button stopButton; + private Button newButton; + private Button settingsButton; + private HBox buttonBox; + + private StackPane superRoot; + private VBox root; + private BusyView busyView; + + private transient DesktopPadViewController controller; // Reference to its controller + + public DesktopPadView() { + controller = new DesktopPadViewController(this); + setupView(); + } + + private void setupView() { + superRoot = new StackPane(); + root = new VBox(); + busyView = new BusyView(superRoot); + + indexLabel = new Label(); + + loopLabel = new Label(); // Active über Visible + loopLabel.setGraphic(new FontIcon(FontAwesomeType.REPEAT)); + + triggerLabel = new Label(); + triggerLabel.setGraphic(new FontIcon(FontAwesomeType.EXTERNAL_LINK)); + + errorLabel = new Label(); + errorLabel.setGraphic(new FontIcon(FontAwesomeType.WARNING)); + + timeLabel = new Label(); + + infoBox = new HBox(); // childern in addDefaultButton() + infoBox.setSpacing(5); + + preview = new HBox(); + HBox.setHgrow(preview, Priority.ALWAYS); + VBox.setVgrow(preview, Priority.ALWAYS); + + HBox.setHgrow(timeLabel, Priority.ALWAYS); + timeLabel.setMaxWidth(Double.MAX_VALUE); + timeLabel.setAlignment(Pos.CENTER_RIGHT); + + playBar = new ProgressBar(0); + playBar.prefWidthProperty().bind(root.widthProperty()); + + // Buttons + playButton = new Button("", new FontIcon(FontAwesomeType.PLAY)); + playButton.setFocusTraversable(false); + playButton.setOnAction(controller); + pauseButton = new Button("", new FontIcon(FontAwesomeType.PAUSE)); + pauseButton.setFocusTraversable(false); + pauseButton.setOnAction(controller); + stopButton = new Button("", new FontIcon(FontAwesomeType.STOP)); + stopButton.setFocusTraversable(false); + stopButton.setOnAction(controller); + newButton = new Button("", new FontIcon(FontAwesomeType.FOLDER_OPEN)); + newButton.setFocusTraversable(false); + newButton.setOnAction(controller); + settingsButton = new Button("", new FontIcon(FontAwesomeType.GEAR)); + settingsButton.setFocusTraversable(false); + settingsButton.setOnAction(controller); + + // Button HBOX + buttonBox = new HBox(); // childern in addDefaultButton() + + root.getChildren().addAll(infoBox, preview, playBar, buttonBox); + superRoot.getChildren().addAll(root); + } + + @Override + public IPadContentView getContentView() { + return previewContent; + } + + @Override + public void setContentView(Pad pad) { + if (previewContent != null) { + previewContent.deinit(); + } + + if (pad != null) { + PadContent content = pad.getContent(); + if (content != null) { + try { + PadContentRegistry registry = PlayPadPlugin.getRegistryCollection().getPadContents(); + PadContentConnect connect = registry.getComponent(content.getType()); + + previewContent = connect.getPadContentPreview(pad, preview); + Node node = previewContent.getNode(); + + node.getStyleClass().addAll("pad-title", "pad" + pad.getIndex() + "-title"); + + // Copy Pseudoclasses + for (PseudoClass pseudoClass : superRoot.getPseudoClassStates()) { + node.pseudoClassStateChanged(pseudoClass, true); + } + + preview.getChildren().setAll(node); + return; + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + EmptyPadView view = new EmptyPadView(preview); + if (pad != null) { + view.getStyleClass().addAll("pad-title", "pad" + pad.getIndex() + "-title"); + } else { + view.getStyleClass().addAll("pad-title"); + } + preview.getChildren().setAll(view); + } + + @Override + public IPadViewController getViewController() { + return controller; + } + + @Override + public Pane getRootNode() { + return superRoot; + } + + @Override + public void enableDragAndDropDesignMode(boolean enable) { + pseudoClassState(PseudoClasses.DRAG_CLASS, enable); + } + + @Override + public void showBusyView(boolean enable) { + busyView.showProgress(enable); + } + + public void setTitle(String text) { + this.indexLabel.setText(text); + } + + public void setProgress(double progress) { + this.playBar.setProgress(progress); + } + + public ProgressBar getPlayBar() { + return playBar; + } + + @Override + public void pseudoClassState(PseudoClass pseudoClass, boolean active) { + superRoot.pseudoClassStateChanged(pseudoClass, active); + indexLabel.pseudoClassStateChanged(pseudoClass, active); + timeLabel.pseudoClassStateChanged(pseudoClass, active); + loopLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + triggerLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + errorLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + + if (preview != null) { + preview.getChildren().forEach(i -> i.pseudoClassStateChanged(pseudoClass, active)); + } + + playBar.pseudoClassStateChanged(pseudoClass, active); + + playButton.getGraphic().pseudoClassStateChanged(pseudoClass, active); + pauseButton.getGraphic().pseudoClassStateChanged(pseudoClass, active); + stopButton.getGraphic().pseudoClassStateChanged(pseudoClass, active); + newButton.getGraphic().pseudoClassStateChanged(pseudoClass, active); + settingsButton.getGraphic().pseudoClassStateChanged(pseudoClass, active); + } + + @Override + public void setStyle(String string) { + superRoot.setStyle(string); + + } + + @Override + public void setErrorLabelActive(boolean b) { + errorLabel.setVisible(b); + } + + Button getPlayButton() { + return playButton; + } + + Button getPauseButton() { + return pauseButton; + } + + Button getStopButton() { + return stopButton; + } + + Button getNewButton() { + return newButton; + } + + Button getSettingsButton() { + return settingsButton; + } + + public void setIndex(int indexReadable) { + indexLabel.setText(String.valueOf(indexReadable)); + } + + public Property<Boolean> loopLabelVisibleProperty() { + return loopLabel.visibleProperty(); + } + + public void setTriggerLabelActive(boolean hasTriggerItems) { + triggerLabel.setVisible(hasTriggerItems); + } + + public void setTime(String time) { + if (time == null) { + timeLabel.setText(""); + } else { + timeLabel.setText(time); + } + } + + @Override + public void addDefaultElement(Pad pad) { + if (pad != null) { + if (pad.getContent() != null) { + if (pad.getContent() instanceof Pauseable) { + buttonBox.getChildren().setAll(playButton, pauseButton, stopButton, newButton, settingsButton); + } else { + buttonBox.getChildren().setAll(playButton, stopButton, newButton, settingsButton); + } + } else { + buttonBox.getChildren().setAll(newButton, settingsButton); + } + } + infoBox.getChildren().setAll(indexLabel, loopLabel, triggerLabel, errorLabel, timeLabel); + + // Buttons unten Full Width + buttonBox.prefWidthProperty().bind(superRoot.widthProperty()); + for (Node child : buttonBox.getChildren()) { + if (child instanceof Region) { + HBox.setHgrow(child, Priority.ALWAYS); + ((Region) child).setMaxWidth(Double.MAX_VALUE); + } + } + + // alle Labels in der InfoBox sollen die gleiche Höhe haben, damit die Icons auf gleicher höhe sind + for (Node child : infoBox.getChildren()) { + if (child instanceof Label) { + ((Label) child).setMaxHeight(Double.MAX_VALUE); + } + } + } + + @Override + public void applyStyleClasses(int index) { + superRoot.getStyleClass().addAll("pad", "pad" + index); + + indexLabel.getStyleClass().addAll("pad-index", "pad" + index + "-index", "pad-info", "pad" + index + "-info"); + timeLabel.getStyleClass().addAll("pad-time", "pad" + index + "-time", "pad-info", "pad" + index + "-info"); + loopLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + triggerLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + errorLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + + preview.getChildren().forEach(i -> i.getStyleClass().addAll("pad-title", "pad" + index + "-title")); + + playBar.getStyleClass().addAll("pad-playbar", "pad" + index + "-playbar"); + + playButton.getStyleClass().addAll("pad-button", "pad" + index + "-button"); + pauseButton.getStyleClass().addAll("pad-button", "pad" + index + "-button"); + stopButton.getStyleClass().addAll("pad-button", "pad" + index + "-button"); + newButton.getStyleClass().addAll("pad-button", "pad" + index + "-button"); + settingsButton.getStyleClass().addAll("pad-button", "pad" + index + "-button"); + + playButton.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + pauseButton.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + stopButton.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + newButton.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + settingsButton.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + + buttonBox.getStyleClass().add("pad-button-box"); + root.getStyleClass().add("pad-root"); + } + + @Override + public void removeStyleClasses() { + Pad pad = getViewController().getPad(); + int index = pad.getIndex(); + + superRoot.getStyleClass().removeAll("pad", "pad" + index); + + indexLabel.getStyleClass().removeAll("pad-index", "pad" + index + "-index", "pad-info", "pad" + index + "-info"); + timeLabel.getStyleClass().removeAll("pad-time", "pad" + index + "-time", "pad-info", "pad" + index + "-info"); + loopLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + triggerLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + errorLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + + preview.getChildren().forEach(i -> i.getStyleClass().removeAll("pad-title", "pad" + index + "-title")); + + playBar.getStyleClass().removeAll("pad-playbar", "pad" + index + "-playbar"); + + playButton.getStyleClass().removeAll("pad-button", "pad" + index + "-button"); + pauseButton.getStyleClass().removeAll("pad-button", "pad" + index + "-button"); + stopButton.getStyleClass().removeAll("pad-button", "pad" + index + "-button"); + newButton.getStyleClass().removeAll("pad-button", "pad" + index + "-button"); + settingsButton.getStyleClass().removeAll("pad-button", "pad" + index + "-button"); + + playButton.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + pauseButton.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + stopButton.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + newButton.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + settingsButton.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + + buttonBox.getStyleClass().add("pad-button-box"); + root.getStyleClass().add("pad-root"); + } + + @Override + public void highlightView(int milliSecounds) { + // FadeableColor stopColor = new FadeableColor(ModernColor.GRAY1.getColorHi(), ModernColor.GRAY1.getColorLow()); + // FadeableColor playColor = new FadeableColor(ModernColor.BLUE1.getColorHi(), ModernColor.BLUE1.getColorLow()); + // + // ModernDesignAnimator.animateWarn(controller, stopColor, playColor, Duration.seconds(3)); + // Pad pad = controller.getPad(); + // + // Warning warning = pad.getWarning(); + // + // if (pad.isCustomLayout()) { + // pad.getLayout().handleWarning(controller, warning, Profile.currentProfile().currentLayout()); + // } else { + // Profile.currentProfile().currentLayout().handleWarning(controller, warning); + // } + + PulseTranslation pulseTranslation = new PulseTranslation(superRoot, null, 0.1); + pulseTranslation.play(); + } + + public void clearIndex() { + indexLabel.setText(""); + } + + public void clearTime() { + timeLabel.setText(""); + } + + public void clearPreviewContent() { + if (previewContent != null) { + previewContent.deinit(); + } + setContentView(null); + } + + @Override + public void setPlaybarVisible(boolean visible) { + playBar.setVisible(visible); + } + + @Override + public void setPlayBarProgress(double value) { + playBar.setProgress(value); + } +} diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..0384a296e54b07d84224036dd1865e53d0717f57 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java @@ -0,0 +1,399 @@ +package de.tobias.playpad.layout.desktop; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Set; + +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.Strings; +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadContentRegistry; +import de.tobias.playpad.pad.PadStatus; +import de.tobias.playpad.pad.TimeMode; +import de.tobias.playpad.pad.conntent.PadContent; +import de.tobias.playpad.pad.conntent.PadContentConnect; +import de.tobias.playpad.pad.conntent.play.Durationable; +import de.tobias.playpad.pad.listener.IPadPositionListener; +import de.tobias.playpad.pad.listener.PadContentListener; +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.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; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.pad.PadSettingsViewController; +import de.tobias.playpad.viewcontroller.pad.PadDragListener; +import de.tobias.utils.application.ApplicationUtils; +import de.tobias.utils.util.FileUtils; +import de.tobias.utils.util.Localization; +import javafx.beans.value.ChangeListener; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Node; +import javafx.stage.FileChooser; +import javafx.stage.FileChooser.ExtensionFilter; +import javafx.stage.Stage; +import javafx.util.Duration; + +public class DesktopPadViewController implements IPadViewController, EventHandler<ActionEvent> { + + protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; + private static final String OPEN_FOLDER = "openFolder"; + private static final String DURATION_FORMAT = "%d:%02d"; + + private DesktopPadView padView; + private Pad pad; + + private PadLockedListener padLockedListener; + private PadStatusListener padStatusListener; + private PadContentListener padContentListener; + private PadDurationListener padDurationListener; + private IPadPositionListener padPositionListener; + + private PadDragListener padDragListener; + + public DesktopPadViewController(DesktopPadView padView) { + this.padView = padView; + + padLockedListener = new PadLockedListener(this); + padStatusListener = new PadStatusListener(this); + padContentListener = new PadContentListener(this); + 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 + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + profileSettings.lockedProperty().addListener(padLockedListener); + } + + @Override + public Pad getPad() { + return pad; + } + + @Override + public IPadView getView() { + return padView; + } + + @Override + public void setupPad(Pad pad) { + pad.setController(this); + + this.pad = pad; + + try { + // Settings + padView.setIndex(pad.getIndexReadable()); + padView.loopLabelVisibleProperty().bind(pad.getPadSettings().loopProperty()); + padView.setTriggerLabelActive(pad.getPadSettings().hasTriggerItems()); + + // Update Listener + padContentListener.setPad(pad); + padPositionListener.setPad(pad); + + // Pad Content Chnage + pad.contentProperty().addListener(padContentListener); + // Pad Status Change + pad.statusProperty().addListener(padStatusListener); + + // First Listener call with new data + padContentListener.changed(null, null, pad.getContent()); // Add Duration listener + padStatusListener.changed(null, null, pad.getStatus()); + + padDragListener = new PadDragListener(pad, padView); + } catch (Exception e) { + e.printStackTrace(); + } + + padView.applyStyleClasses(pad.getIndex()); + padView.setContentView(pad); + } + + @Override + public void removePad() { + if (padView != null && pad != null) { + + padView.clearIndex(); + padView.clearPreviewContent(); + padView.clearTime(); + + padView.setTriggerLabelActive(false); + + padView.loopLabelVisibleProperty().unbind(); + + pad.contentProperty().removeListener(padContentListener); + pad.statusProperty().removeListener(padStatusListener); + + if (pad.getContent() instanceof Durationable) { + Durationable durationable = (Durationable) pad.getContent(); + durationable.durationProperty().removeListener(padDurationListener); + durationable.positionProperty().removeListener(padPositionListener); + } + pad.setController(null); + padDragListener = null; + + // GUI Cleaning + padPositionListener.stopWaning(); + padView.removeStyleClasses(); + } + + this.padDragListener = null; + this.pad = null; + + // Hide Loading Animation + if (getView() != null) + getView().showBusyView(false); + + } + + @Override + public void handle(ActionEvent event) { + if (event.getSource() == padView.getPlayButton()) { + onPlay(); + } else if (event.getSource() == padView.getPauseButton()) { + onPause(); + } else if (event.getSource() == padView.getStopButton()) { + onStop(); + } else if (event.getSource() == padView.getNewButton()) { + try { + onNew(event); + } catch (NoSuchComponentException e) { + // TODO Error Handling + e.printStackTrace(); + } + } else if (event.getSource() == padView.getSettingsButton()) { + onSettings(); + } + } + + private void onPlay() { + if (pad.getContent() != null) { + pad.setStatus(PadStatus.PLAY); + } + } + + private void onPause() { + if (pad.getContent() != null) { + pad.setStatus(PadStatus.PAUSE); + } + } + + private void onStop() { + if (pad.getContent() != null) { + pad.setStatus(PadStatus.STOP); + } + } + + private void onNew(ActionEvent event) throws NoSuchComponentException { + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); + if (pad.getProject() != null) { + if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getActivePlayers() > 0) { + return; + } + } + + FileChooser chooser = new FileChooser(); + PadContentRegistry registry = PlayPadPlugin.getRegistryCollection().getPadContents(); + + // File Extension + ExtensionFilter extensionFilter = new ExtensionFilter(Localization.getString(Strings.File_Filter_Media), + registry.getSupportedFileTypes()); + chooser.getExtensionFilters().add(extensionFilter); + + // Last Folder + Object openFolder = ApplicationUtils.getApplication().getUserDefaults().getData(OPEN_FOLDER); + if (openFolder != null) { + File folder = new File(openFolder.toString()); + chooser.setInitialDirectory(folder); + } + + File file = chooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow()); + if (file != null) { + Path path = file.toPath(); + + Set<PadContentConnect> connects = registry.getPadContentConnectsForFile(file.toPath()); + if (!connects.isEmpty()) { + if (connects.size() > 1) { + FileDragOptionView hud = new FileDragOptionView(padView.getRootNode()); + hud.showDropOptions(connects, connect -> + { + if (connect != null) { + setNewPadContent(file, path, connect); + hud.hide(); + } + }); + } else { + PadContentConnect connect = connects.iterator().next(); + setNewPadContent(file, path, connect); + } + } + + ApplicationUtils.getApplication().getUserDefaults().setData(OPEN_FOLDER, path.getParent().toString()); + } + } + + private void setNewPadContent(File file, Path path, PadContentConnect connect) { + PadContent content = pad.getContent(); + if (pad.getContent() == null || !pad.getContent().getType().equals(connect.getType())) { + content = connect.newInstance(pad); + this.pad.setContent(content); + } + + try { + content.handlePath(file.toPath()); + } catch (NoSuchComponentException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); + } + + private void onSettings() { + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); + IMainViewController mvc = PlayPadPlugin.getImplementation().getMainViewController(); + + if (mvc != null) { + if (pad.getProject() != null) { + if (settings.isLiveMode() && settings.isLiveModeSettings() && pad.getProject().getActivePlayers() > 0) { + return; + } + } + + Stage owner = mvc.getStage(); + + PadSettingsViewController padSettingsViewController = new PadSettingsViewController(pad, owner); + padSettingsViewController.getStage().setOnHiding(ev -> + { + if (padView != null && pad != null) + padView.setTriggerLabelActive(pad.getPadSettings().hasTriggerItems()); + }); + padSettingsViewController.getStage().show(); + } + } + + @Override + public void updateTimeLabel() { + if (pad.getContent() != null && pad.getStatus() != PadStatus.EMPTY && pad.getStatus() != PadStatus.ERROR) { + if (pad.getContent() instanceof Durationable) { + Durationable durationable = (Durationable) pad.getContent(); + + Duration duration = durationable.getDuration(); + Duration position = durationable.getPosition(); + + if (duration != null) { + // Nur Gesamtzeit anzeigen + if (pad.getStatus() == PadStatus.READY || position == null) { + String time = durationToString(duration); + padView.setTime(time); + padView.getPlayBar().setProgress(0); + } else { + // Play/Gesamtzeit anzeigen + TimeMode timeMode = pad.getPadSettings().getTimeMode(); + + if (timeMode == TimeMode.REST) { + Duration leftTime = duration.subtract(position); + + padView.setTime("- " + durationToString(leftTime)); + } else if (timeMode == TimeMode.PLAYED) { + padView.setTime(durationToString(position)); + } else if (timeMode == TimeMode.BOTH) { + String time = durationToString(position); + String totalTime = durationToString(duration); + + padView.setTime(time + "/" + totalTime); + } + } + } + return; + } + } + padView.getPlayBar().setProgress(0); + padView.setTime(null); + } + + public String durationToString(Duration value) { + if (value != null) { + int secounds = (int) ((value.toMillis() / 1000) % 60); + int minutes = (int) ((value.toMillis() / (1000 * 60)) % 60); + String time = String.format(DURATION_FORMAT, minutes, secounds); + return time; + } else { + return null; + } + } + + @Override + public void updateButtonDisable() { + if (pad == null) { + return; + } + if (pad.getContent() != null) { + if (pad.getStatus() == PadStatus.PLAY) { + padView.getPlayButton().setDisable(true); + padView.getPauseButton().setDisable(false); + padView.getStopButton().setDisable(false); + padView.getNewButton().setDisable(true); + padView.getSettingsButton().setDisable(false); + } else if (pad.getStatus() == PadStatus.PAUSE) { + padView.getPlayButton().setDisable(false); + padView.getPauseButton().setDisable(true); + padView.getStopButton().setDisable(false); + padView.getNewButton().setDisable(true); + padView.getSettingsButton().setDisable(false); + } else if (pad.getStatus() == PadStatus.STOP) { + padView.getPlayButton().setDisable(false); + padView.getPauseButton().setDisable(true); + padView.getStopButton().setDisable(true); + padView.getNewButton().setDisable(true); + padView.getSettingsButton().setDisable(false); + } else if (pad.getStatus() == PadStatus.READY) { + padView.getPlayButton().setDisable(false); + padView.getPauseButton().setDisable(true); + padView.getStopButton().setDisable(true); + padView.getNewButton().setDisable(false); + padView.getSettingsButton().setDisable(false); + } else if (pad.getStatus() == PadStatus.ERROR) { + padView.getPlayButton().setDisable(true); + padView.getPauseButton().setDisable(true); + padView.getStopButton().setDisable(true); + padView.getNewButton().setDisable(false); + padView.getSettingsButton().setDisable(false); + } + } else if (pad.getStatus() == PadStatus.EMPTY || pad.getStatus() == PadStatus.ERROR || pad.getContent() == null + || !pad.getContent().isPadLoaded()) { + padView.getPlayButton().setDisable(true); + padView.getPauseButton().setDisable(true); + padView.getStopButton().setDisable(true); + padView.getNewButton().setDisable(false); + padView.getSettingsButton().setDisable(false); + } + + if (Profile.currentProfile().getProfileSettings().isLocked()) { + padView.getNewButton().setDisable(true); + padView.getSettingsButton().setDisable(true); + } + } + + @Override + public IPadPositionListener getPadPositionListener() { + return padPositionListener; + } + + @Override + public ChangeListener<Duration> getPadDurationListener() { + return padDurationListener; + } + + public PadDragListener getPadDragListener() { + return padDragListener; + } +} diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java new file mode 100644 index 0000000000000000000000000000000000000000..ddeb4138d48ceeb95bdbc745018e02049f0884c5 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java @@ -0,0 +1,53 @@ +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; + +public class DesktopSearchController implements EventHandler<ActionEvent> { + + private TextField textField; + private Alertable alertable; + + public DesktopSearchController(TextField textField, Alertable alertable) { + this.textField = textField; + this.alertable = alertable; + } + + private int currentIndex = 0; + + @Override + public void handle(ActionEvent event) { + if (textField.getText().isEmpty()) { + return; + } + + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + main: for (int i = currentIndex; i < currentProject.getPadCount(); i++) { + Pad pad = currentProject.getPad(i); + if (pad.getStatus() != PadStatus.EMPTY) { + if (pad.getName().startsWith(textField.getText())) { + while (pad.getController() == null) { + if (!PlayPadPlugin.getImplementation().getMainViewController() + .showPage(PlayPadPlugin.getImplementation().getMainViewController().getPage() + 1)) { + break main; + } + } + pad.getController().getView().highlightView(3); + currentIndex = i + 1; + return; + } + } + } + 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/modern/ModernLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutConnect.java deleted file mode 100644 index d26077ad8100763c42f1b2cd49046670f49cf4bd..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutConnect.java +++ /dev/null @@ -1,49 +0,0 @@ -package de.tobias.playpad.layout.modern; - -import de.tobias.playpad.Strings; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.LayoutConnect; -import de.tobias.playpad.viewcontroller.CartLayoutViewController; -import de.tobias.playpad.viewcontroller.GlobalLayoutViewController; -import de.tobias.playpad.viewcontroller.layout.ModernLayoutCartViewController; -import de.tobias.playpad.viewcontroller.layout.ModernLayoutGlobalViewController; -import de.tobias.utils.util.Localization; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; - -public class ModernLayoutConnect extends LayoutConnect { - - private static final String TYPE = "modern"; - - @Override - public StringProperty displayProperty() { - return new SimpleStringProperty(Localization.getString(Strings.Layout_Modern_Name)); - } - - @Override - public String getType() { - return TYPE; - } - - @Override - public CartLayout newCartLayout() { - return new ModernLayoutCart(); - } - - @Override - public GlobalLayout newGlobalLayout() { - return new ModernLayoutGlobal(); - } - - @Override - public CartLayoutViewController getCartLayoutViewController(CartLayout cartLayout) { - return new ModernLayoutCartViewController(cartLayout); - } - - @Override - public GlobalLayoutViewController getGlobalLayoutViewController(GlobalLayout globalLayout) { - return new ModernLayoutGlobalViewController(globalLayout); - } - -} diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java new file mode 100644 index 0000000000000000000000000000000000000000..07126bc71dff9c20f93a7e497463b508d07d739e --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java @@ -0,0 +1,68 @@ +package de.tobias.playpad.layout.touch; + +import java.util.Stack; + +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<IPadView> recyclingStack; + + public TouchMainLayoutConnect() { + recyclingStack = new Stack<>(); + } + + @Override + public String getType() { + return TYPE; + } + + @Override + public String name() { + return Localization.getString(Strings.MainLayout_Touch); + } + + @Override + public MenuToolbarViewController createMenuToolbar(IMainViewController mainViewRef) { + if (touchMainLayoutConnect == null) { + touchMainLayoutConnect = new TouchMenuToolbarViewController(mainViewRef); + } + + return touchMainLayoutConnect; + } + + @Override + public IPadView createPadView() { + if (!recyclingStack.isEmpty()) { + return recyclingStack.pop(); + } + return new TouchPadView(); + } + + @Override + public void recyclePadView(IPadView padView) { + recyclingStack.push(padView); + } + + @Override + public String getStylesheet() { + return "de/tobias/playpad/assets/style/touch.css"; + } + +} diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..347361cd08b6c8ebde4b661e2259f438e71df8fe --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java @@ -0,0 +1,144 @@ +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; +import de.tobias.playpad.view.main.MenuType; +import de.tobias.playpad.viewcontroller.main.BasicMenuToolbarViewController; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.utils.ui.icon.FontIcon; +import de.tobias.utils.util.Localization; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.MenuItem; +import javafx.scene.control.Slider; + +public class TouchMenuToolbarViewController extends BasicMenuToolbarViewController { + + @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()); + this.mainViewController = mainViewController; + + toolbarHBox.prefWidthProperty().bind(toolbar.widthProperty().subtract(25)); + toolbarHBox.prefHeightProperty().bind(toolbar.minHeightProperty()); + + // Schriftgröße Icons + FontIcon icon = (FontIcon) volumeDownLabel.getGraphic(); + icon.setSize(35); + icon = (FontIcon) volumeUpLabel.getGraphic(); + icon.setSize(35); + } + + @Override + public void initPageButtons() { + pageHBox.getChildren().clear(); + + if (openProject == null) { + return; + } + + 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.setFocusTraversable(false); + button.setOnAction(this); + pageHBox.getChildren().add(button); + } + } + + @Override + 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) {} + + @Override + public void setFullScreenActive(boolean fullScreenActive) {} + + @Override + public void addToolbarItem(Node node) { + iconHbox.getChildren().add(node); + } + + @Override + public void removeToolbarItem(Node node) { + iconHbox.getChildren().remove(node); + } + + @Override + public void addMenuItem(MenuItem item, MenuType type) {} + + @Override + public void removeMenuItem(MenuItem item) {} + + @Override + public void deinit() {} + + private int currentPage = 0; + + @Override + public void highlightPageButton(int index) { + if (index >= 0) { + if (pageHBox.getChildren().size() > currentPage) { + Node removeNode = pageHBox.getChildren().get(currentPage); + removeNode.getStyleClass().remove(CURRENT_PAGE_BUTTON); + } + + if (pageHBox.getChildren().size() > index) { + Node newNode = pageHBox.getChildren().get(index); + newNode.getStyleClass().add(CURRENT_PAGE_BUTTON); + currentPage = index; + } + } + } + + @Override + public Slider getVolumeSlider() { + return volumeSlider; + } + + // Event Handler + @FXML + void closeMenuItemHandler(ActionEvent event) { + MainLayoutConnect defaultLayout = PlayPadPlugin.getRegistryCollection().getMainLayouts().getDefault(); + + Profile.currentProfile().getProfileSettings().setMainLayoutType(defaultLayout.getType()); + mainViewController.setMainLayout(defaultLayout); + } + + @Override + public void handle(ActionEvent event) { + if (event.getSource() instanceof Button) { + Button button = (Button) event.getSource(); + int page = (int) button.getUserData(); + mainViewController.showPage(page); + } + } + +} \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java new file mode 100644 index 0000000000000000000000000000000000000000..8d68d5e6a08f27cc473292cf326b645f3d36c1ef --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java @@ -0,0 +1,300 @@ +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.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; +import javafx.scene.Node; +import javafx.scene.control.Label; +import javafx.scene.control.ProgressBar; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; + +public class TouchPadView implements IPadView { + + private Label indexLabel; + private Label loopLabel; + private Label triggerLabel; + private Label errorLabel; + + private HBox infoBox; + private Label timeLabel; + + private HBox preview; + private IPadContentView previewContent; + + private ProgressBar playBar; + + private StackPane superRoot; + private VBox root; + private BusyView busyView; + + private transient TouchPadViewController controller; // Reference to its controller + + public TouchPadView() { + controller = new TouchPadViewController(this); + setupView(); + } + + private void setupView() { + superRoot = new StackPane(); + root = new VBox(); + busyView = new BusyView(superRoot); + + indexLabel = new Label(); + + loopLabel = new Label(); // Active über Visible + loopLabel.setGraphic(new FontIcon(FontAwesomeType.REPEAT)); + + triggerLabel = new Label(); + triggerLabel.setGraphic(new FontIcon(FontAwesomeType.EXTERNAL_LINK)); + + errorLabel = new Label(); + errorLabel.setGraphic(new FontIcon(FontAwesomeType.WARNING)); + + timeLabel = new Label(); + + infoBox = new HBox(); // childern in addDefaultButton() + infoBox.setSpacing(5); + + preview = new HBox(); + HBox.setHgrow(preview, Priority.ALWAYS); + VBox.setVgrow(preview, Priority.ALWAYS); + + HBox.setHgrow(timeLabel, Priority.ALWAYS); + timeLabel.setMaxWidth(Double.MAX_VALUE); + timeLabel.setAlignment(Pos.CENTER_RIGHT); + + playBar = new ProgressBar(0); + playBar.prefWidthProperty().bind(root.widthProperty()); + + root.getChildren().addAll(infoBox, preview, playBar); + superRoot.getChildren().addAll(root); + + if (OS.isWindows() && User32X.isTouchAvailable()) { + superRoot.setOnTouchPressed(controller); + playBar.setOnTouchPressed(controller); + } else { + superRoot.setOnMouseClicked(controller); + playBar.setOnMouseClicked(controller); + } + } + + @Override + public IPadContentView getContentView() { + return previewContent; + } + + @Override + public void setContentView(Pad pad) { + if (previewContent != null) { + previewContent.deinit(); + } + + if (pad != null) { + PadContent content = pad.getContent(); + if (content != null) { + try { + PadContentConnect connect = PlayPadPlugin.getRegistryCollection().getPadContents().getComponent(content.getType()); + previewContent = connect.getPadContentPreview(pad, preview); + Node node = previewContent.getNode(); + + node.getStyleClass().addAll("pad-title", "pad" + pad.getIndex() + "-title"); + + // Copy Pseudoclasses + for (PseudoClass pseudoClass : superRoot.getPseudoClassStates()) { + node.pseudoClassStateChanged(pseudoClass, true); + } + + preview.getChildren().setAll(node); + return; + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + EmptyPadView view = new EmptyPadView(preview); + if (pad != null) { + view.getStyleClass().addAll("pad-title", "pad" + pad.getIndex() + "-title"); + } else { + view.getStyleClass().addAll("pad-title"); + } + preview.getChildren().setAll(view); + } + + @Override + public IPadViewController getViewController() { + return controller; + } + + @Override + public Pane getRootNode() { + return superRoot; + } + + @Override + public void enableDragAndDropDesignMode(boolean enable) { + pseudoClassState(PseudoClasses.DRAG_CLASS, enable); + } + + @Override + public void showBusyView(boolean enable) { + busyView.showProgress(enable); + } + + public void setTitle(String text) { + this.indexLabel.setText(text); + } + + public void setProgress(double progress) { + this.playBar.setProgress(progress); + } + + public ProgressBar getPlayBar() { + return playBar; + } + + @Override + public void pseudoClassState(PseudoClass pseudoClass, boolean active) { + superRoot.pseudoClassStateChanged(pseudoClass, active); + indexLabel.pseudoClassStateChanged(pseudoClass, active); + timeLabel.pseudoClassStateChanged(pseudoClass, active); + loopLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + triggerLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + errorLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + + if (preview != null) { + preview.getChildren().forEach(i -> i.pseudoClassStateChanged(pseudoClass, active)); + } + + playBar.pseudoClassStateChanged(pseudoClass, active); + } + + @Override + public void setStyle(String string) { + superRoot.setStyle(string); + } + + @Override + public void setErrorLabelActive(boolean b) { + errorLabel.setVisible(b); + } + + public void setIndex(int indexReadable) { + indexLabel.setText(String.valueOf(indexReadable)); + } + + public Property<Boolean> loopLabelVisibleProperty() { + return loopLabel.visibleProperty(); + } + + public void setTriggerLabelActive(boolean hasTriggerItems) { + triggerLabel.setVisible(hasTriggerItems); + } + + public void setTime(String time) { + if (time == null) { + timeLabel.setText(""); + } else { + timeLabel.setText(time); + } + } + + @Override + public void addDefaultElement(Pad pad) { + infoBox.getChildren().setAll(indexLabel, loopLabel, triggerLabel, errorLabel, timeLabel); + + // alle Labels in der InfoBox sollen die gleiche Höhe haben, damit die Icons auf gleicher höhe sind + for (Node child : infoBox.getChildren()) { + if (child instanceof Label) { + ((Label) child).setMaxHeight(Double.MAX_VALUE); + } + } + } + + @Override + public void applyStyleClasses(int index) { + superRoot.getStyleClass().addAll("pad", "pad" + index); + + indexLabel.getStyleClass().addAll("pad-index", "pad" + index + "-index", "pad-info", "pad" + index + "-info"); + timeLabel.getStyleClass().addAll("pad-time", "pad" + index + "-time", "pad-info", "pad" + index + "-info"); + loopLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + triggerLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + errorLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon"); + + preview.getChildren().forEach(i -> i.getStyleClass().addAll("pad-title", "pad" + index + "-title")); + + playBar.getStyleClass().addAll("pad-playbar", "pad" + index + "-playbar"); + + root.getStyleClass().add("pad-root"); + } + + @Override + public void removeStyleClasses() { + Pad pad = getViewController().getPad(); + int index = pad.getIndex(); + + superRoot.getStyleClass().removeAll("pad", "pad" + index); + + indexLabel.getStyleClass().removeAll("pad-index", "pad" + index + "-index", "pad-info", "pad" + index + "-info"); + timeLabel.getStyleClass().removeAll("pad-time", "pad" + index + "-time", "pad-info", "pad" + index + "-info"); + loopLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + triggerLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + errorLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + index + "-icon"); + + preview.getChildren().forEach(i -> i.getStyleClass().removeAll("pad-title", "pad" + index + "-title")); + + playBar.getStyleClass().removeAll("pad-playbar", "pad" + index + "-playbar"); + + root.getStyleClass().add("pad-root"); + } + + @Override + public void highlightView(int milliSecounds) { + + } + + public void clearIndex() { + indexLabel.setText(""); + } + + public void clearTime() { + timeLabel.setText(""); + } + + public void clearPreviewContent() { + if (previewContent != null) { + previewContent.deinit(); + } + setContentView(null); + } + + @Override + public void setPlaybarVisible(boolean visible) { + playBar.setVisible(visible); + } + + @Override + public void setPlayBarProgress(double value) { + playBar.setProgress(value); + } +} diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..11ef9044b35d086c2f6dbcce2d21a24b8714d7e4 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java @@ -0,0 +1,239 @@ +package de.tobias.playpad.layout.touch; + +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadStatus; +import de.tobias.playpad.pad.TimeMode; +import de.tobias.playpad.pad.conntent.play.Durationable; +import de.tobias.playpad.pad.listener.IPadPositionListener; +import de.tobias.playpad.pad.listener.PadContentListener; +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.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; +import javafx.beans.value.ChangeListener; +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 IPadViewController, EventHandler<Event> { + + protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; + private static final String DURATION_FORMAT = "%d:%02d"; + + private TouchPadView padView; + private Pad pad; + + private PadLockedListener padLockedListener; + private PadStatusListener padStatusListener; + private PadContentListener padContentListener; + private PadDurationListener padDurationListener; + private IPadPositionListener padPositionListener; + + private PadDragListener padDragListener; + + public TouchPadViewController(TouchPadView padView) { + this.padView = padView; + + padLockedListener = new PadLockedListener(this); + padStatusListener = new PadStatusListener(this); + padContentListener = new PadContentListener(this); + 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 + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + profileSettings.lockedProperty().addListener(padLockedListener); + } + + @Override + public Pad getPad() { + return pad; + } + + @Override + public IPadView getView() { + return padView; + } + + @Override + public void setupPad(Pad pad) { + pad.setController(this); + + this.pad = pad; + + try { + // Settings + padView.setIndex(pad.getIndexReadable()); + padView.loopLabelVisibleProperty().bind(pad.getPadSettings().loopProperty()); + padView.setTriggerLabelActive(pad.getPadSettings().hasTriggerItems()); + + // Update Listener + padContentListener.setPad(pad); + padPositionListener.setPad(pad); + + // Pad Content Chnage + pad.contentProperty().addListener(padContentListener); + // Pad Status Change + pad.statusProperty().addListener(padStatusListener); + + // First Listener call with new data + padContentListener.changed(null, null, pad.getContent()); // Add + // Duration + // listener + padStatusListener.changed(null, null, pad.getStatus()); + + padDragListener = new PadDragListener(pad, padView); + } catch (Exception e) { + e.printStackTrace(); + } + + padView.applyStyleClasses(pad.getIndex()); + padView.setContentView(pad); + } + + @Override + public void removePad() { + if (padView != null && pad != null) { + + padView.clearIndex(); + padView.clearPreviewContent(); + padView.clearTime(); + + padView.setTriggerLabelActive(false); + + padView.loopLabelVisibleProperty().unbind(); + + pad.contentProperty().removeListener(padContentListener); + pad.statusProperty().removeListener(padStatusListener); + + if (pad.getContent() instanceof Durationable) { + Durationable durationable = (Durationable) pad.getContent(); + durationable.durationProperty().removeListener(padDurationListener); + durationable.positionProperty().removeListener(padPositionListener); + } + pad.setController(null); + padDragListener = null; + + // GUI Cleaning + padPositionListener.stopWaning(); + padView.removeStyleClasses(); + } + + this.padDragListener = null; + this.pad = null; + } + + @Override + public void handle(Event event) { + if (event instanceof MouseEvent) { + if (event.getEventType() == MouseEvent.MOUSE_CLICKED) { + MouseEvent mouseEvent = (MouseEvent) event; + if (mouseEvent.getButton() == MouseButton.PRIMARY) { + if (pad.getStatus() == PadStatus.PLAY) { + onStop(); + } else { + onPlay(); + } + } + } + } else if (event instanceof TouchEvent) { + if (pad.getStatus() == PadStatus.PLAY) { + onStop(); + } else { + onPlay(); + } + } + } + + private void onPlay() { + if (pad.getContent() != null) { + pad.setStatus(PadStatus.PLAY); + } + } + + private void onStop() { + if (pad.getContent() != null) { + pad.setStatus(PadStatus.STOP); + } + } + + @Override + public void updateTimeLabel() { + if (pad.getContent() != null && pad.getStatus() != PadStatus.EMPTY && pad.getStatus() != PadStatus.ERROR) { + if (pad.getContent() instanceof Durationable) { + Durationable durationable = (Durationable) pad.getContent(); + + Duration duration = durationable.getDuration(); + Duration position = durationable.getPosition(); + + if (duration != null) { + // Nur Gesamtzeit anzeigen + if (pad.getStatus() == PadStatus.READY || position == null) { + String time = durationToString(duration); + padView.setTime(time); + padView.getPlayBar().setProgress(0); + } else { + // Play/Gesamtzeit anzeigen + TimeMode timeMode = pad.getPadSettings().getTimeMode(); + + if (timeMode == TimeMode.REST) { + Duration leftTime = duration.subtract(position); + + padView.setTime("- " + durationToString(leftTime)); + } else if (timeMode == TimeMode.PLAYED) { + padView.setTime(durationToString(position)); + } else if (timeMode == TimeMode.BOTH) { + String time = durationToString(position); + String totalTime = durationToString(duration); + + padView.setTime(time + "/" + totalTime); + } + } + } + return; + } + } + padView.getPlayBar().setProgress(0); + padView.setTime(null); + } + + public String durationToString(Duration value) { + if (value != null) { + int secounds = (int) ((value.toMillis() / 1000) % 60); + int minutes = (int) ((value.toMillis() / (1000 * 60)) % 60); + String time = String.format(DURATION_FORMAT, minutes, secounds); + return time; + } else { + return null; + } + } + + @Override + public void updateButtonDisable() { + // Not needed in touch mode + } + + @Override + public IPadPositionListener getPadPositionListener() { + return padPositionListener; + } + + @Override + public ChangeListener<Duration> getPadDurationListener() { + return padDurationListener; + } + + public PadDragListener getPadDragListener() { + return padDragListener; + } +} diff --git a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java index cef5c4b1c0498a6bcbd65b17c759a3b15f464ea1..2d9b220013ad986e4502722119ec04c91fe980fb 100644 --- a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java +++ b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java @@ -1,23 +1,29 @@ 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; import org.dom4j.Element; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.audio.AudioHandler; import de.tobias.playpad.audio.AudioRegistry; import de.tobias.playpad.audio.Equalizable; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.pad.conntent.Durationable; -import de.tobias.playpad.pad.conntent.Fadeable; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.pad.conntent.Pauseable; +import de.tobias.playpad.pad.conntent.path.SinglePathContent; +import de.tobias.playpad.pad.conntent.play.Durationable; +import de.tobias.playpad.pad.conntent.play.Fadeable; +import de.tobias.playpad.pad.conntent.play.Pauseable; import de.tobias.playpad.project.ProjectExporter; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileSettings; import de.tobias.utils.util.ZipFile; import javafx.animation.Transition; import javafx.application.Platform; @@ -28,7 +34,7 @@ import javafx.beans.value.ChangeListener; import javafx.scene.media.AudioEqualizer; import javafx.util.Duration; -public class AudioContent extends PadContent implements Pauseable, Durationable, Fadeable, Equalizable { +public class AudioContent extends PadContent implements Pauseable, Durationable, Fadeable, Equalizable, SinglePathContent { private static final String TYPE = "audio"; @@ -47,38 +53,36 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, super(pad); volumeListener = (a, b, c) -> { - audioHandler.setVolume(c.doubleValue(), Profile.currentProfile().getProfileSettings().getVolume(), pad.getCustomVolume()); + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + audioHandler.setVolume(c.doubleValue(), profileSettings.getVolume(), pad.getCustomVolume()); }; customVolumeListener = (a, b, c) -> { - audioHandler.setVolume(pad.getVolume(), Profile.currentProfile().getProfileSettings().getVolume(), c.doubleValue()); + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + audioHandler.setVolume(pad.getPadSettings().getVolume(), profileSettings.getVolume(), c.doubleValue()); }; } - public AudioContent(Pad pad, Path path) { - this(pad); - this.path = path; - } - + @Override public Path getPath() { return path; } - public void setPath(Path path) { - this.path = path; - } - @Override - public void handlePath(Path path) { + public void handlePath(Path path) throws NoSuchComponentException, IOException { + // handle old media unloadMedia(); - setPath(path); + + this.path = getRealPath(path); + + // handle new media loadMedia(); } @Override public void setMasterVolume(double masterVolume) { if (audioHandler != null) { - audioHandler.setVolume(getPad().getVolume(), masterVolume, getPad().getCustomVolume()); + audioHandler.setVolume(getPad().getPadSettings().getVolume(), masterVolume, getPad().getCustomVolume()); } } @@ -113,18 +117,18 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, Pad pad = getPad(); - if (pad.getFade().getFadeIn().toMillis() > 0) { + if (pad.getPadSettings().getFade().getFadeIn().toMillis() > 0) { double masterVolume = Profile.currentProfile().getProfileSettings().getVolume(); audioHandler.setVolume(0, masterVolume, pad.getCustomVolume()); transition = new Transition() { { - setCycleDuration(pad.getFade().getFadeIn()); + setCycleDuration(pad.getPadSettings().getFade().getFadeIn()); } @Override protected void interpolate(double frac) { - audioHandler.setVolume(frac * pad.getVolume(), masterVolume, pad.getCustomVolume()); + audioHandler.setVolume(frac * pad.getPadSettings().getVolume(), masterVolume, pad.getCustomVolume()); } }; transition.setOnFinished(e -> @@ -141,17 +145,19 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, transition.stop(); } - if (getPad().getFade().getFadeOut().toMillis() > 0) { + if (getPad().getPadSettings().getFade().getFadeOut().toMillis() > 0) { transition = new Transition() { { - setCycleDuration(getPad().getFade().getFadeOut()); + setCycleDuration(getPad().getPadSettings().getFade().getFadeOut()); } @Override protected void interpolate(double frac) { double masterVolume = Profile.currentProfile().getProfileSettings().getVolume(); - audioHandler.setVolume(getPad().getVolume() - frac * getPad().getVolume(), masterVolume, getPad().getCustomVolume()); + PadSettings padSettings = getPad().getPadSettings(); + + audioHandler.setVolume(padSettings.getVolume() - frac * padSettings.getVolume(), masterVolume, getPad().getCustomVolume()); } }; transition.setOnFinished(event -> @@ -159,7 +165,9 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, onFinish.run(); double masterVolume = Profile.currentProfile().getProfileSettings().getVolume(); - audioHandler.setVolume(getPad().getVolume(), masterVolume, getPad().getCustomVolume()); + PadSettings padSettings = getPad().getPadSettings(); + + audioHandler.setVolume(padSettings.getVolume(), masterVolume, getPad().getCustomVolume()); transition = null; }); transition.play(); @@ -211,14 +219,17 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, @Override public void loadMedia() { - audioHandler = AudioRegistry.geAudioType().createAudioHandler(this); + // init audio implementation + AudioRegistry audioRegistry = PlayPadPlugin.getRegistryCollection().getAudioHandlers(); + audioHandler = audioRegistry.getCurrentAudioHandler().createAudioHandler(this); + if (Files.exists(path)) { audioHandler.loadMedia(new Path[] { path }); durationProperty.bind(audioHandler.durationProperty()); positionProperty.bind(audioHandler.positionProperty()); - getPad().volumeProperty().addListener(volumeListener); + getPad().getPadSettings().volumeProperty().addListener(volumeListener); getPad().customVolumeProperty().addListener(customVolumeListener); } else { getPad().throwException(path, new FileNotFoundException()); @@ -230,7 +241,7 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, durationProperty.unbind(); positionProperty.unbind(); - getPad().volumeProperty().removeListener(volumeListener); + getPad().getPadSettings().volumeProperty().removeListener(volumeListener); getPad().customVolumeProperty().removeListener(customVolumeListener); if (audioHandler != null) diff --git a/PlayWall/src/de/tobias/playpad/pad/content/AudioContentConnect.java b/PlayWall/src/de/tobias/playpad/pad/content/AudioContentConnect.java index c111f13bee8d9a7c49f937d741697f31363270c2..538d4d411600c0e4dc39c80441242c6ed4bb0b2c 100644 --- a/PlayWall/src/de/tobias/playpad/pad/content/AudioContentConnect.java +++ b/PlayWall/src/de/tobias/playpad/pad/content/AudioContentConnect.java @@ -5,8 +5,8 @@ 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.viewcontroller.SettingsTabViewController; -import de.tobias.playpad.viewcontroller.option.AudioTabViewController; +import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; +import de.tobias.playpad.viewcontroller.option.profile.AudioTabViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.util.Localization; @@ -59,7 +59,7 @@ public class AudioContentConnect extends PadContentConnect { } @Override - public SettingsTabViewController getSettingsTabViewController(boolean activePlayer) { + public ProfileSettingsTabViewController getSettingsTabViewController(boolean activePlayer) { return new AudioTabViewController(activePlayer); } diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadContentListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadContentListener.java index 54a756291bf94eadf7604b74b0df646beb44b913..b27598ecfbac618ab3cce68b8a5172f19ac07f61 100644 --- a/PlayWall/src/de/tobias/playpad/pad/listener/PadContentListener.java +++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadContentListener.java @@ -1,18 +1,18 @@ package de.tobias.playpad.pad.listener; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.conntent.Durationable; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.viewcontroller.pad.PadViewController; +import de.tobias.playpad.pad.conntent.play.Durationable; +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 PadViewController controller; + private IPadViewController controller; - public PadContentListener(PadViewController controller) { + public PadContentListener(IPadViewController controller) { this.controller = controller; } @@ -23,8 +23,8 @@ public class PadContentListener implements ChangeListener<PadContent> { @Override public void changed(ObservableValue<? extends PadContent> observable, PadContent oldValue, PadContent newValue) { // wenn Content change, update preview & buttons - controller.getParent().setPreviewContent(pad); - controller.getParent().addDefaultButton(pad); + controller.getView().setContentView(pad); + controller.getView().addDefaultElement(pad); controller.updateButtonDisable(); controller.updateTimeLabel(); @@ -38,7 +38,7 @@ public class PadContentListener implements ChangeListener<PadContent> { // set new content listener / bindings if (newValue instanceof Durationable) { - controller.getParent().showPlaybar(true); + controller.getView().setPlaybarVisible(true); Durationable durationable = (Durationable) newValue; durationable.durationProperty().addListener(controller.getPadDurationListener()); @@ -47,7 +47,7 @@ public class PadContentListener implements ChangeListener<PadContent> { // Init Duration controller.getPadDurationListener().changed(null, null, durationable.getDuration()); } else { - controller.getParent().showPlaybar(false); + controller.getView().setPlaybarVisible(false); } } } diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadDurationListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadDurationListener.java index 2058d3a1e30e520e032487d185561cdb0f8f6b33..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.viewcontroller.pad.PadViewController; +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 PadViewController controller; + private IPadViewController controller; - public PadDurationListener(PadViewController 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 9acff1c3e103808c2f210a29fb9b6056da75e752..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.viewcontroller.pad.PadViewController; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; public class PadLockedListener implements ChangeListener<Boolean> { - private PadViewController controller; + private IPadViewController controller; - public PadLockedListener(PadViewController 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 bdb5f35a716c1a17f448d408aa1cb5d004314f11..f1ddd7d222840089fb73f7f63bbf8a69f6e783e2 100644 --- a/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java +++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java @@ -1,26 +1,27 @@ package de.tobias.playpad.pad.listener; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.pad.conntent.Durationable; -import de.tobias.playpad.pad.conntent.Fadeable; 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.IPadViewController; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.Warning; -import de.tobias.playpad.viewcontroller.pad.PadViewController; -import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.util.Duration; -public class PadPositionListener implements ChangeListener<Duration>, Runnable { +public class PadPositionListener implements Runnable, IPadPositionListener { private Pad pad; - private PadViewController controller; + private IPadViewController controller; - public PadPositionListener(PadViewController controller) { + public PadPositionListener(IPadViewController controller) { this.controller = controller; } + @Override public void setPad(Pad pad) { this.pad = pad; } @@ -56,16 +57,16 @@ public class PadPositionListener implements ChangeListener<Duration>, Runnable { private void updateDuration(Duration newValue, Durationable durationable, Duration totalDuration) { double value = newValue.toMillis() / totalDuration.toMillis(); - controller.getParent().getPlayBar().setProgress(value); + controller.getView().setPlayBarProgress(value); // Label (Restlaufzeit) controller.updateTimeLabel(); // Warning nur wenn kein Loop und nur wenn Play, da sonst schon anderer Zustand und Warning nicht mehr richtig Reseted // wird - if (!pad.isLoop() && pad.getStatus() == PadStatus.PLAY) { + if (!pad.getPadSettings().isLoop() && pad.getStatus() == PadStatus.PLAY) { // Warning - Warning warning = pad.getWarning(); + Warning warning = pad.getPadSettings().getWarning(); Duration rest = durationable.getDuration().subtract(newValue); double seconds = rest.toSeconds(); @@ -76,6 +77,7 @@ public class PadPositionListener implements ChangeListener<Duration>, Runnable { } } + @Override public void setSend(boolean send) { this.send = send; } @@ -85,10 +87,11 @@ public class PadPositionListener implements ChangeListener<Duration>, Runnable { */ @Override public void run() { - Warning warning = pad.getWarning(); + PadSettings padSettings = pad.getPadSettings(); + Warning warning = padSettings.getWarning(); - if (pad.isCustomLayout()) { - pad.getLayout().handleWarning(controller, warning, Profile.currentProfile().currentLayout()); + if (padSettings.isCustomLayout()) { + padSettings.getLayout().handleWarning(controller, warning, Profile.currentProfile().currentLayout()); } else { Profile.currentProfile().currentLayout().handleWarning(controller, warning); } @@ -102,17 +105,20 @@ public class PadPositionListener implements ChangeListener<Duration>, Runnable { warningThread.start(); } + @Override public void stopWaning() { if (warningThread != null) { warningThread.interrupt(); warningThread = null; } - if (pad.isCustomLayout()) { - pad.getLayout().stopWarning(controller); + PadSettings padSettings = pad.getPadSettings(); + + if (padSettings.isCustomLayout()) { + padSettings.getLayout().stopWarning(controller); } else { Profile.currentProfile().currentLayout().stopWarning(controller); } - controller.getParent().setStyle(""); + controller.getView().setStyle(""); } } diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadStatusListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadStatusListener.java index 117e2aa04ccf8572531368b51767dc99feb5b06c..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.viewcontroller.pad.PadViewController; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; public class PadStatusListener implements ChangeListener<PadStatus> { - private PadViewController controller; + private IPadViewController controller; - public PadStatusListener(PadViewController controller) { + public PadStatusListener(IPadViewController controller) { this.controller = controller; } @@ -18,7 +18,7 @@ public class PadStatusListener implements ChangeListener<PadStatus> { public void changed(ObservableValue<? extends PadStatus> observable, PadStatus oldValue, PadStatus newValue) { controller.updateButtonDisable(); controller.updateTimeLabel(); - controller.getParent().setErrorLabelActive(false); + controller.getView().setErrorLabelActive(false); switch (newValue) { case PLAY: @@ -26,47 +26,47 @@ public class PadStatusListener implements ChangeListener<PadStatus> { controller.getPadPositionListener().setSend(false); // UI Styling - controller.getParent().pseudoClassState(PseudoClasses.PLAY_CALSS, true); + controller.getView().pseudoClassState(PseudoClasses.PLAY_CALSS, true); break; case PAUSE: controller.getPadPositionListener().stopWaning(); - controller.getParent().pseudoClassState(PseudoClasses.PLAY_CALSS, false); - controller.getParent().pseudoClassState(PseudoClasses.FADE_CLASS, false); - controller.getParent().pseudoClassState(PseudoClasses.WARN_CLASS, false); + controller.getView().pseudoClassState(PseudoClasses.PLAY_CALSS, false); + controller.getView().pseudoClassState(PseudoClasses.FADE_CLASS, false); + controller.getView().pseudoClassState(PseudoClasses.WARN_CLASS, false); break; case STOP: controller.getPadPositionListener().stopWaning(); - controller.getParent().pseudoClassState(PseudoClasses.PLAY_CALSS, false); - controller.getParent().pseudoClassState(PseudoClasses.FADE_CLASS, false); - controller.getParent().pseudoClassState(PseudoClasses.WARN_CLASS, false); - controller.getParent().setStyle(""); + controller.getView().pseudoClassState(PseudoClasses.PLAY_CALSS, false); + controller.getView().pseudoClassState(PseudoClasses.FADE_CLASS, false); + controller.getView().pseudoClassState(PseudoClasses.WARN_CLASS, false); + controller.getView().setStyle(""); break; case READY: controller.getPadPositionListener().stopWaning(); - controller.getParent().pseudoClassState(PseudoClasses.PLAY_CALSS, false); - controller.getParent().pseudoClassState(PseudoClasses.FADE_CLASS, false); - controller.getParent().pseudoClassState(PseudoClasses.WARN_CLASS, false); - controller.getParent().setStyle(""); // Cleanup from warning UI + controller.getView().pseudoClassState(PseudoClasses.PLAY_CALSS, false); + controller.getView().pseudoClassState(PseudoClasses.FADE_CLASS, false); + controller.getView().pseudoClassState(PseudoClasses.WARN_CLASS, false); + controller.getView().setStyle(""); // Cleanup from warning UI break; case ERROR: - controller.getParent().setErrorLabelActive(true); + controller.getView().setErrorLabelActive(true); controller.getPadPositionListener().stopWaning(); - controller.getParent().pseudoClassState(PseudoClasses.PLAY_CALSS, false); - controller.getParent().pseudoClassState(PseudoClasses.FADE_CLASS, false); - controller.getParent().pseudoClassState(PseudoClasses.WARN_CLASS, false); - controller.getParent().setStyle(""); // Cleanup from warning UI + controller.getView().pseudoClassState(PseudoClasses.PLAY_CALSS, false); + controller.getView().pseudoClassState(PseudoClasses.FADE_CLASS, false); + controller.getView().pseudoClassState(PseudoClasses.WARN_CLASS, false); + controller.getView().setStyle(""); // Cleanup from warning UI break; case EMPTY: controller.getPadPositionListener().stopWaning(); - controller.getParent().pseudoClassState(PseudoClasses.PLAY_CALSS, false); - controller.getParent().pseudoClassState(PseudoClasses.FADE_CLASS, false); - controller.getParent().pseudoClassState(PseudoClasses.WARN_CLASS, false); - controller.getParent().setStyle(""); // Cleanup from warning UI + controller.getView().pseudoClassState(PseudoClasses.PLAY_CALSS, false); + controller.getView().pseudoClassState(PseudoClasses.FADE_CLASS, false); + controller.getView().pseudoClassState(PseudoClasses.WARN_CLASS, false); + controller.getView().setStyle(""); // Cleanup from warning UI break; default: break; diff --git a/PlayWall/src/de/tobias/playpad/view/HelpMenuItem.java b/PlayWall/src/de/tobias/playpad/view/HelpMenuItem.java new file mode 100644 index 0000000000000000000000000000000000000000..25a935f3accd14176f1b7b5288808a64e3a9664a --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/view/HelpMenuItem.java @@ -0,0 +1,51 @@ +package de.tobias.playpad.view; + +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.geometry.Pos; +import javafx.scene.control.CustomMenuItem; +import javafx.scene.control.Label; +import javafx.scene.control.Menu; +import javafx.scene.control.MenuItem; +import javafx.scene.control.TextField; +import javafx.scene.layout.HBox; + +/** + * Hilfe Menü. + * + * @author tobias + * + * @since 5.1.0 + */ +public class HelpMenuItem extends CustomMenuItem implements ChangeListener<String> { + + private Menu helpMenu; + + public HelpMenuItem(Menu parentMenu) { + this.helpMenu = parentMenu; + + setHideOnClick(false); + + Label label = new Label("Suchen nach (Beta): "); // BETA i18n + TextField textfield = new TextField(); + textfield.textProperty().addListener(this); + + HBox hbox = new HBox(14, label, textfield); + hbox.setAlignment(Pos.CENTER_LEFT); + setContent(hbox); + } + + private void clearMenu() { + helpMenu.getItems().removeIf(i -> i != this); + } + + @Override + public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { + clearMenu(); + + for (char c : newValue.toCharArray()) { + MenuItem item = new MenuItem(String.valueOf(c)); + helpMenu.getItems().add(item); + } + } +} diff --git a/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java b/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java index 98522dabed70961ed87ff28c781cffbf6bd55dee..5ae0d9f6a0f9de033b308e52034cb98731109147 100644 --- a/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java +++ b/PlayWall/src/de/tobias/playpad/view/MapperOverviewViewController.java @@ -5,10 +5,13 @@ import java.util.List; import java.util.Set; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.action.Action; import de.tobias.playpad.action.mapper.Mapper; -import de.tobias.playpad.action.mapper.MapperRegistry; +import de.tobias.playpad.action.mapper.MapperConnect; import de.tobias.playpad.action.mapper.MapperViewController; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.registry.Registry; import de.tobias.playpad.viewcontroller.IMapperOverviewViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -55,26 +58,48 @@ public class MapperOverviewViewController implements IMapperOverviewViewControll headline.setUnderline(true); root.getChildren().addAll(headline, mappingView, addMappingBox); - Set<String> types = MapperRegistry.getTypes(); + Registry<MapperConnect> registry = PlayPadPlugin.getRegistryCollection().getMappers(); + Set<String> types = registry.getTypes(); types.stream().sorted().forEach(item -> { - Button button = new Button(MapperRegistry.getMapperConnect(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); button.setOnAction(e -> { // Adds a mapper to the action - MapperViewController controller = onAddMapper(item); - controller.showInputMapperUI(); + try { + MapperViewController controller = onAddMapper(item); + boolean result = controller.showInputMapperUI(); + + // Delete Mapper wenn Eingabe abgebrochen wurde + if (!result) { + mappingView.getChildren().removeAll(controller.getParent().getParent()); + action.removeMapper(controller.getMapper()); + } + } catch (NoSuchComponentException ex) { + // TODO Error Handling + ex.printStackTrace(); + } }); addMappingBox.getChildren().add(button); }); } - private MapperViewController onAddMapper(String type) { - Mapper mapper = MapperRegistry.getMapperConnect(type).createNewMapper(); + private MapperViewController onAddMapper(String type) throws NoSuchComponentException { + Registry<MapperConnect> registry = PlayPadPlugin.getRegistryCollection().getMappers(); + + Mapper mapper = registry.getComponent(type).createNewMapper(); action.addMapper(mapper); return addMapperView(type, mapper); } diff --git a/PlayWall/src/de/tobias/playpad/view/PadView.java b/PlayWall/src/de/tobias/playpad/view/PadView.java index 73fea8d8e2d3f7f6a20a1b5f4c89c3f2b3dc47d3..7bed59870b8766e073b1bd2ea48830436641b170 100644 --- a/PlayWall/src/de/tobias/playpad/view/PadView.java +++ b/PlayWall/src/de/tobias/playpad/view/PadView.java @@ -1,12 +1,13 @@ package de.tobias.playpad.view; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.pad.conntent.PadContentRegistry; -import de.tobias.playpad.pad.conntent.Pauseable; -import de.tobias.playpad.pad.conntent.UnkownPadContentException; +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.IPadViewController; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.viewcontroller.IPadView; import de.tobias.playpad.viewcontroller.pad.PadViewController; import de.tobias.utils.ui.icon.FontAwesomeType; @@ -181,13 +182,15 @@ public class PadView extends StackPane implements IPadView { PadContent content = pad.getContent(); if (content != null) { try { - previewContent = PadContentRegistry.getPadContentConnect(content.getType()).getPadContentPreview(pad, preview); + PadContentConnect connect = PlayPadPlugin.getRegistryCollection().getPadContents().getComponent(content.getType()); + previewContent = connect.getPadContentPreview(pad, preview); Node node = previewContent.getNode(); node.getStyleClass().addAll("pad-title", "pad" + pad.getIndex() + "-title"); preview.getChildren().setAll(node); return; - } catch (UnkownPadContentException e) { + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block e.printStackTrace(); } } 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/actions/CartActionsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java index 6b559d479ee894aca9cf5b6c7a4b9455c264b1f6..6326b9c7015b56a4e6510a47bde8cd42676311bd 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java @@ -5,21 +5,18 @@ import java.util.List; import org.controlsfx.control.SegmentedButton; import de.tobias.playpad.PlayPadMain; -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.settings.Profile; -import de.tobias.playpad.settings.ProfileSettings; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.viewcontroller.IMappingTabViewController; import de.tobias.utils.ui.ContentViewController; -import de.tobias.utils.util.Localization; import javafx.fxml.FXML; import javafx.scene.control.ToggleButton; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.ColumnConstraints; import javafx.scene.layout.GridPane; -import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.scene.layout.RowConstraints; import javafx.scene.layout.VBox; @@ -36,7 +33,6 @@ import javafx.scene.layout.VBox; public class CartActionsViewController extends ContentViewController { @FXML private VBox buttonVbox; - @FXML private HBox pageHbox; private ToggleGroup cartsToggle; @FXML private GridPane gridPane; @@ -51,25 +47,11 @@ public class CartActionsViewController extends ContentViewController { this.mapping = mapping; this.parentController = parentController; - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); + ProjectSettings settings = currentProject.getSettings(); showCartButtons(settings, 0); VBox.setVgrow(gridPane, Priority.ALWAYS); - - SegmentedButton segmentedButton = new SegmentedButton(); - for (int i = 0; i < settings.getPageCount(); i++) { - ToggleButton button = new ToggleButton(Localization.getString(Strings.UI_Window_Main_PageButton, i + 1)); - button.setOnAction(e -> - { - int page = Integer.valueOf(((ToggleButton) e.getSource()).getUserData().toString()); - showCartButtons(Profile.currentProfile().getProfileSettings(), page); - }); - button.setUserData(i); - segmentedButton.getButtons().add(button); - } - segmentedButton.getStyleClass().add(SegmentedButton.STYLE_CLASS_DARK); - pageHbox.getChildren().add(segmentedButton); - segmentedButton.getButtons().get(0).setSelected(true); // Select First Toggle } @Override @@ -77,7 +59,7 @@ public class CartActionsViewController extends ContentViewController { buttonVbox.minHeightProperty().bind(buttonVbox.heightProperty()); } - private void showCartButtons(ProfileSettings settings, int page) { + private void showCartButtons(ProjectSettings settings, int page) { gridPane.getChildren().clear(); gridPane.getColumnConstraints().clear(); @@ -98,25 +80,26 @@ public class CartActionsViewController extends ContentViewController { cartsToggle = new ToggleGroup(); - int startValue = (page * settings.getColumns() * settings.getRows()); + int index = 0; - for (int x = 0; x < settings.getColumns(); x++) { - for (int y = 0; y < settings.getRows(); y++) { - int index = (settings.getColumns() * y + x) + startValue; - ToggleButton button = new ToggleButton(String.valueOf(index + 1)); + for (int y = 0; y < settings.getRows(); y++) { + for (int x = 0; x < settings.getColumns(); x++) { + ToggleButton button = new ToggleButton(String.valueOf(index++ + 1)); button.setMaxWidth(Double.MAX_VALUE); - button.setUserData(index); + button.setUserData(new int[] { x, y }); button.getStyleClass().add(SegmentedButton.STYLE_CLASS_DARK); // Show the right cart settings button.selectedProperty().addListener((a, b, c) -> { if (c) { - int id = Integer.valueOf(button.getUserData().toString()); + int[] data = (int[]) button.getUserData(); + int currentX = data[0]; + int currentY = data[1]; List<CartAction> cartActions = mapping.getActions(CartActionConnect.TYPE); for (CartAction action : cartActions) { - if (action.getCart() == id) { + if (action.getX() == currentX && action.getY() == currentY) { ContentViewController actionViewController = action.getSettingsViewController(); cartActionContainer.getChildren().setAll(actionViewController.getParent()); cartActionContainer.setVisible(true); 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/ThemeCell.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ThemeCell.java index 64cdd06b4cd2fc28efc3f790c720ea428bad01b6..16d9e226bac912fabc7506e47c7a5f8e863179aa 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ThemeCell.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ThemeCell.java @@ -1,7 +1,7 @@ package de.tobias.playpad.viewcontroller.cell; import de.tobias.playpad.Strings; -import de.tobias.playpad.layout.classic.Theme; +import de.tobias.playpad.design.classic.Theme; import de.tobias.utils.util.Localization; import javafx.scene.control.ListCell; 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 483f161325b4b2555cb54a6fec8b59aa7e176f23..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.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.pad.conntent.PadContentRegistry; -import de.tobias.playpad.pad.conntent.UnkownPadContentException; 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; @@ -18,6 +11,7 @@ import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; import javafx.stage.Stage; +// TODO Rewrite --> Extract Button Listeners public class FixCell extends TableCell<PadException, PadException> { private Stage stage; @@ -37,26 +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 = PadContentRegistry.getPadContentConnect(content.getType()); - - if (Files.exists(path) && PadContentConnect.isFileSupported(path, padContentConnect)) { - content.handlePath(path); - pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); - pad.removeException(item); - } - } catch (UnkownPadContentException e) { - e.printStackTrace(); - } - } - }); + notExistsButton.setOnAction(new IOExceptionButtonListener(item, stage, notExistsExButton)); vbox.getChildren().add(notExistsButton); break; @@ -64,26 +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 = PadContentRegistry.getPadContentConnect(content.getType()); - - if (Files.exists(path) && PadContentConnect.isFileSupported(path, padContentConnect)) { - content.handlePath(path); - pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); - pad.removeException(item); - } - } catch (UnkownPadContentException e) { - 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/layout/ClassicLayoutCartViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicCartDesignViewController.java similarity index 83% rename from PlayWall/src/de/tobias/playpad/viewcontroller/layout/ClassicLayoutCartViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicCartDesignViewController.java index 197ff4d30e76056f5c313d784f68b031c080747e..169b7bccf480fb19030a05c42fbb51ff129065c9 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ClassicLayoutCartViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicCartDesignViewController.java @@ -1,18 +1,18 @@ -package de.tobias.playpad.viewcontroller.layout; +package de.tobias.playpad.viewcontroller.design; import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.classic.ClassicCartLayout; -import de.tobias.playpad.viewcontroller.CartLayoutViewController; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.classic.ClassicCartDesign; +import de.tobias.playpad.viewcontroller.CartDesignViewController; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.ColorPicker; import javafx.scene.paint.Color; -public class ClassicLayoutCartViewController extends CartLayoutViewController { +public class ClassicCartDesignViewController extends CartDesignViewController { - private ClassicCartLayout layout; + private ClassicCartDesign layout; @FXML private ColorPicker playgroundColorPicker; @FXML private ColorPicker backgroundColorPicker; @@ -24,9 +24,9 @@ public class ClassicLayoutCartViewController extends CartLayoutViewController { @FXML private Button resetButton; - public ClassicLayoutCartViewController(CartLayout layout) { + public ClassicCartDesignViewController(CartDesign layout) { super("classicLayoutCart", "de/tobias/playpad/assets/view/option/layout/", PlayPadMain.getUiResourceBundle(), layout); - setLayout((ClassicCartLayout) layout); + setLayout((ClassicCartDesign) layout); } @Override @@ -70,7 +70,7 @@ public class ClassicLayoutCartViewController extends CartLayoutViewController { titleLabelColorPicker.valueProperty().addListener((a, b, c) -> layout.setTitleLabelColor(c)); } - public void setLayout(ClassicCartLayout defaultLayout) { + public void setLayout(ClassicCartDesign defaultLayout) { this.layout = defaultLayout; backgroundColorPicker.setValue(layout.getBackgroundColor()); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ClassicLayoutGlobalViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicGlobalDesignViewController.java similarity index 87% rename from PlayWall/src/de/tobias/playpad/viewcontroller/layout/ClassicLayoutGlobalViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicGlobalDesignViewController.java index 780435cc39b4974383dd0ecde0539ecd961610ec..d27b88dd43431697726f1251c642dfdc00de6ebf 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ClassicLayoutGlobalViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicGlobalDesignViewController.java @@ -1,12 +1,12 @@ -package de.tobias.playpad.viewcontroller.layout; +package de.tobias.playpad.viewcontroller.design; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.LayoutConnect; -import de.tobias.playpad.layout.classic.ClassicGlobalLayout; -import de.tobias.playpad.layout.classic.Theme; -import de.tobias.playpad.viewcontroller.GlobalLayoutViewController; +import de.tobias.playpad.design.GlobalDesign; +import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.design.classic.ClassicGlobalDesign; +import de.tobias.playpad.design.classic.Theme; +import de.tobias.playpad.viewcontroller.GlobalDesignViewController; import de.tobias.playpad.viewcontroller.cell.ThemeCell; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -18,11 +18,11 @@ import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.util.converter.IntegerStringConverter; -public class ClassicLayoutGlobalViewController extends GlobalLayoutViewController { +public class ClassicGlobalDesignViewController extends GlobalDesignViewController { - private ClassicGlobalLayout layout; + private ClassicGlobalDesign layout; - @FXML private ComboBox<LayoutConnect> layoutTypeComboBox; + @FXML private ComboBox<DesignConnect> layoutTypeComboBox; @FXML private ComboBox<Theme> programLayoutComboBox; @FXML private ColorPicker accentColorChooser; @@ -43,11 +43,11 @@ public class ClassicLayoutGlobalViewController extends GlobalLayoutViewControlle @FXML private Button resetButton; - public ClassicLayoutGlobalViewController(GlobalLayout layout) { + public ClassicGlobalDesignViewController(GlobalDesign layout) { super("classicLayoutGlobal", "de/tobias/playpad/assets/view/option/layout/", PlayPadMain.getUiResourceBundle(), layout); - setLayout((ClassicGlobalLayout) layout); + setLayout((ClassicGlobalDesign) layout); - ClassicGlobalLayout cl = (ClassicGlobalLayout) layout; + ClassicGlobalDesign cl = (ClassicGlobalDesign) layout; programLayoutComboBox.valueProperty().bindBidirectional(cl.themeProperty()); accentColorChooser.setValue(cl.getAccentColor()); customLayoutCheckBox.setSelected(cl.isCustomLayout()); @@ -141,7 +141,7 @@ public class ClassicLayoutGlobalViewController extends GlobalLayoutViewControlle }); } - public void setLayout(ClassicGlobalLayout defaultLayout) { + public void setLayout(ClassicGlobalDesign defaultLayout) { this.layout = defaultLayout; backgroundColorPicker.setValue(layout.getBackgroundColor()); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutCartViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java similarity index 82% rename from PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutCartViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java index f5c5214f553b3393422300a8142b29022fb74c6c..fbda591aa744faa54b000b0b47622d76fbd5de94 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutCartViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.viewcontroller.layout; +package de.tobias.playpad.viewcontroller.design; import java.util.function.Consumer; @@ -7,17 +7,17 @@ import org.controlsfx.control.PopOver.ArrowLocation; import de.tobias.playpad.DisplayableColor; import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.modern.ModernColor; -import de.tobias.playpad.layout.modern.ModernLayoutCart; +import de.tobias.playpad.design.CartDesign; +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.CartLayoutViewController; +import de.tobias.playpad.viewcontroller.CartDesignViewController; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; -public class ModernLayoutCartViewController extends CartLayoutViewController { +public class ModernCartDesignViewController extends CartDesignViewController { @FXML private Button backgroundColorButton; @FXML private Button playColorButton; @@ -25,15 +25,15 @@ public class ModernLayoutCartViewController extends CartLayoutViewController { @FXML private Button resetButton; - private ModernLayoutCart cartLayout; + private ModernCartDesign cartLayout; private PopOver colorChooser; - public ModernLayoutCartViewController(CartLayout layout) { + public ModernCartDesignViewController(CartDesign layout) { super("modernLayoutCart", "de/tobias/playpad/assets/view/option/layout/", PlayPadMain.getUiResourceBundle(), layout); - if (layout instanceof CartLayout) { - this.cartLayout = (ModernLayoutCart) layout; + if (layout instanceof CartDesign) { + this.cartLayout = (ModernCartDesign) layout; setLayout(); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutGlobalViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java similarity index 86% rename from PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutGlobalViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java index bbda3b0d30dddff4c980f601cd70b1bb8876fc15..19811e5ca8d27854d38315930f809f245f152bb3 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutGlobalViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.viewcontroller.layout; +package de.tobias.playpad.viewcontroller.design; import java.util.function.Consumer; @@ -7,11 +7,11 @@ import org.controlsfx.control.PopOver.ArrowLocation; import de.tobias.playpad.DisplayableColor; import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.modern.ModernColor; -import de.tobias.playpad.layout.modern.ModernLayoutGlobal; +import de.tobias.playpad.design.GlobalDesign; +import de.tobias.playpad.design.modern.ModernColor; +import de.tobias.playpad.design.modern.ModernGlobalDesign; import de.tobias.playpad.view.ColorView; -import de.tobias.playpad.viewcontroller.GlobalLayoutViewController; +import de.tobias.playpad.viewcontroller.GlobalDesignViewController; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; @@ -19,7 +19,7 @@ import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; import javafx.util.converter.IntegerStringConverter; -public class ModernLayoutGlobalViewController extends GlobalLayoutViewController { +public class ModernGlobalDesignViewController extends GlobalDesignViewController { @FXML private Button backgroundColorButton; @FXML private Button playColorButton; @@ -31,15 +31,15 @@ public class ModernLayoutGlobalViewController extends GlobalLayoutViewController @FXML private Button resetButton; - private ModernLayoutGlobal globalLayout; + private ModernGlobalDesign globalLayout; private PopOver colorChooser; - public ModernLayoutGlobalViewController(GlobalLayout layout) { + public ModernGlobalDesignViewController(GlobalDesign layout) { super("modernLayoutGlobal", "de/tobias/playpad/assets/view/option/layout/", PlayPadMain.getUiResourceBundle(), layout); - if (layout instanceof GlobalLayout) { - this.globalLayout = (ModernLayoutGlobal) layout; + if (layout instanceof GlobalDesign) { + this.globalLayout = (ModernGlobalDesign) layout; setLayout(); } 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/PluginViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java index dbe7f9aefae577b2c99d0e62bc95747d84c760df..42341a2c4ebd3b53e96a89c1f079945e4337f675 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java @@ -8,9 +8,11 @@ import org.bukkit.configuration.MemorySection; import de.tobias.playpad.AppUserInfoStrings; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.plugin.Plugin; import de.tobias.playpad.plugin.Plugins; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.update.UpdateChannel; import de.tobias.playpad.viewcontroller.cell.PluginCell; @@ -44,9 +46,10 @@ public class PluginViewController extends ViewController { try { String pluginInfoURL = null; - MemorySection userInfo = ApplicationUtils.getApplication().getInfo().getUserInfo(); - UpdateChannel updateChannel = Profile.currentProfile().getProfileSettings().getUpdateChannel(); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + UpdateChannel updateChannel = globalSettings.getUpdateChannel(); + MemorySection userInfo = ApplicationUtils.getApplication().getInfo().getUserInfo(); if (updateChannel == UpdateChannel.STABLE) { pluginInfoURL = userInfo.getString(AppUserInfoStrings.PLUGINS_URL_STABLE); } else if (updateChannel == UpdateChannel.BETA) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java index 25185126c7e2785dc66c89d749a36c6ec3d200ba..71d6ca6354fbd3c34fddb557ed30c3f5d97e9f77 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java @@ -12,8 +12,8 @@ import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileSettings; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; @@ -45,6 +45,10 @@ public class PrintDialog extends ViewController { super("printDialog", "de/tobias/playpad/assets/dialog/project/", null, PlayPadMain.getUiResourceBundle()); this.project = project; + int pages = project.getSettings().getPageCount(); + for (int i = 0; i < pages; i++) { + pageComboBox.getItems().add(i + 1); + } pageComboBox.getSelectionModel().selectFirst(); getStage().initOwner(owner); @@ -52,11 +56,6 @@ public class PrintDialog extends ViewController { @Override public void init() { - int pages = Profile.currentProfile().getProfileSettings().getPageCount(); - for (int i = 0; i < pages; i++) { - pageComboBox.getItems().add(i + 1); - } - pageComboBox.getSelectionModel().selectedItemProperty().addListener((a, b, c) -> { createPreview(c - 1); @@ -91,16 +90,16 @@ public class PrintDialog extends ViewController { Table table = new Table(); table.setStyle("border:1px solid black;border-collapse:collapse;"); - ProfileSettings profilSettings = Profile.currentProfile().getProfileSettings(); - int i = page * profilSettings.getRows() * profilSettings.getColumns(); + ProjectSettings settings = project.getSettings(); + int i = page * settings.getRows() * settings.getColumns(); - for (int y = 0; y < profilSettings.getRows(); y++) { + for (int y = 0; y < settings.getRows(); y++) { Tr tr = new Tr(); table.appendChild(tr); - for (int x = 0; x < profilSettings.getColumns(); x++) { + for (int x = 0; x < settings.getColumns(); x++) { Td td = new Td(); - td.setStyle("border:1px solid black; width: " + 1000 / (float) profilSettings.getColumns() + td.setStyle("border:1px solid black; width: " + 1000 / (float) settings.getColumns() + "px; padding: 5px; vertical-align: center; text-align: center; min-height: 30px; min-width: 100px;"); Div div = new Div(); div.setStyle("word-break: break-all; white-space: normal;"); 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 new file mode 100644 index 0000000000000000000000000000000000000000..7f7d2de79b4acb530ee57ef4045a2b30678d2cf7 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java @@ -0,0 +1,78 @@ +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.GlobalSettings; +import de.tobias.playpad.settings.keys.Key; +import de.tobias.utils.ui.icon.FontAwesomeType; +import de.tobias.utils.ui.icon.FontIcon; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.control.Menu; +import javafx.scene.control.MenuItem; +import javafx.scene.control.Slider; +import javafx.scene.control.ToolBar; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.HBox; + +public abstract class BasicMenuToolbarViewController extends MenuToolbarViewController implements EventHandler<ActionEvent> { + + // Menu + @FXML protected Label volumeUpLabel; + @FXML protected HBox iconHbox; + + @FXML protected HBox pageHBox; + @FXML protected HBox toolbarHBox; + @FXML protected ToolBar toolbar; + @FXML protected Menu recentOpenMenu; + @FXML protected Slider volumeSlider; + @FXML protected Label volumeDownLabel; + + protected Project openProject; // REFERENCE zu MainViewController + + public BasicMenuToolbarViewController(String name, String path, ResourceBundle localization) { + super(name, path, localization); + } + + @Override + public void init() { + 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); + }); + } + + // Utils + protected void doAction(Runnable run) { + Project project = PlayPadMain.getProgramInstance().getCurrentProject(); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + if (!(project.getActivePlayers() > 0 && globalSettings.isLiveMode())) { + run.run(); + } + } + + protected void setKeyBindingForMenu(MenuItem menuItem, Key key) { + if (key != null) { + if (!key.getKeyCode().isEmpty()) { + KeyCombination keyCode = KeyCombination.valueOf(key.getKeyCode()); + if (keyCode != null) { + menuItem.setAccelerator(keyCode); + } + } + } + } + + @Override + public void setOpenProject(Project project) { + this.openProject = project; + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/LayoutChangedListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/LayoutChangedListener.java new file mode 100644 index 0000000000000000000000000000000000000000..ba47586148b5a1f447444c6672a43e954b706361 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/LayoutChangedListener.java @@ -0,0 +1,14 @@ +package de.tobias.playpad.viewcontroller.main; + +import java.util.List; + +import de.tobias.playpad.view.main.MainLayoutHandler; + +public class LayoutChangedListener { + + public void handle(List<MainLayoutHandler> runnables, MenuToolbarViewController oldToolbar, MenuToolbarViewController newToolbar) { + for (MainLayoutHandler run : runnables) { + run.handle(oldToolbar, newToolbar); + } + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/LockedListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/LockedListener.java new file mode 100644 index 0000000000000000000000000000000000000000..d7b8dbacdc22c070b2a5601f1c8b08876c78cfd4 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/LockedListener.java @@ -0,0 +1,34 @@ +package de.tobias.playpad.viewcontroller.main; + +import de.tobias.utils.ui.icon.FontAwesomeType; +import de.tobias.utils.ui.icon.FontIcon; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.scene.control.Label; + +public class LockedListener implements ChangeListener<Boolean> { + + private IMainViewController mainViewController; + + private Label lockedLabel; + + public LockedListener(IMainViewController mainViewController) { + this.mainViewController = mainViewController; + + lockedLabel = new Label(); + lockedLabel.setGraphic(new FontIcon(FontAwesomeType.LOCK)); + } + + @Override + public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { + if (mainViewController.getMenuToolbarController() != null) { + MenuToolbarViewController menuToolbarViewController = mainViewController.getMenuToolbarController(); + menuToolbarViewController.setLocked(newValue); + if (newValue) { + menuToolbarViewController.addToolbarItem(lockedLabel); + } else { + menuToolbarViewController.removeToolbarItem(lockedLabel); + } + } + } +} 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 8ed2b134f07c501b1ba28832f18dad8c4845560c..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainMenuBarController.java +++ /dev/null @@ -1,388 +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; - -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) { - - @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 7936f3b506680756981a0d53f282a4ed5e7772ff..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainToolbarController.java +++ /dev/null @@ -1,139 +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; - -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 4b4e7031c9dc08d2f3adfd9fd96751405f640808..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,33 +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.layout.CartLayout; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.LayoutColorAssociator; +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.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.viewcontroller.IPadView; +import de.tobias.playpad.settings.keys.KeyCollection; +import de.tobias.playpad.view.main.MainLayoutConnect; +import de.tobias.playpad.view.main.MainLayoutHandler; import de.tobias.playpad.viewcontroller.dialog.ErrorSummaryDialog; +import de.tobias.playpad.viewcontroller.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; @@ -46,50 +44,44 @@ 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.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; @@ -99,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 @@ -132,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 */ @@ -140,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; } - private 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(); } - 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) -> @@ -213,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()) { @@ -226,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()) { - CartLayout layout = pad.getLayout(); - if (layout instanceof LayoutColorAssociator) { - LayoutColorAssociator associator = (LayoutColorAssociator) layout; - layoutStdColor = associator.getAssociatedStandardColor(); - layoutEvColor = associator.getAssociatedEventColor(); - } - } else { - GlobalLayout layout = Profile.currentProfile().currentLayout(); - if (layout instanceof LayoutColorAssociator) { - LayoutColorAssociator associator = (LayoutColorAssociator) 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 - GlobalLayout currentLayout = Profile.currentProfile().currentLayout(); - double minWidth = currentLayout.getMinWidth(profileSettings.getColumns()); - double minHeight = currentLayout.getMinHeight(profileSettings.getRows()); + 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) { @@ -371,185 +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; } @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()) { @@ -586,125 +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(); + public void loadUserCss() { + Scene scene = getStage().getScene(); - // Volume - valueProperty.bindBidirectional(currentProfile.getProfileSettings().volumeProperty()); + // Clear Old + scene.getStylesheets().clear(); - final ProfileSettings profilSettings = currentProfile.getProfileSettings(); - final Mapping activeMapping = currentProfile.getMappings().getActiveMapping(); + // Layout Spezifisches CSS (Base) + if (mainLayout.getStylesheet() != null) { + scene.getStylesheets().add(mainLayout.getStylesheet()); + } - // MIDI - if (profilSettings.isMidiActive() && profilSettings.getMidiDevice() != null) { - // Load known MIDI Device - Worker.runLater(() -> - { - loadMidiDevice(profilSettings.getMidiDevice()); + // design spezific css + if (openProject != null) { + Profile.currentProfile().currentLayout().applyCssMainView(this, getStage(), openProject); + } - applyColorsToMappers(); + Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(openProject); + } - Platform.runLater(() -> - { - // Handle Mapper - if (Profile.currentProfile() != null) { - activeMapping.initFeedback(); - activeMapping.showFeedback(project); - } - }); - }); + /** + * 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) { + 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(); } + } - // WINDOW Settings - menuBarController.getAlwaysOnTopItem().setSelected(profilSettings.isWindowAlwaysOnTop()); - getStage().setAlwaysOnTop(profilSettings.isWindowAlwaysOnTop()); - - setTitle(); - showPage(pageNumber); // Show Mapper Feedback und apply css und zeigt pads + 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 Project getProject() { - return project; + public List<IPadView> getPadViews() { + return padViews; } - public MidiHandler getMidiHandler() { + @Override + public MidiListener getMidiHandler() { return midiHandler; } - public MainToolbarController getToolbarController() { - return toolbarController; + @Override + public MenuToolbarViewController getMenuToolbarController() { + return menuToolbarViewController; } - // Plugins - /** - * Fügt ein MenuItem ins Menu hinzu - * - * @param item - * - * @since 2.0.0 - */ - public void addMenuItem(MenuItem item) { - menuBarController.getExtensionMenu().getItems().add(item); - if (!menuBarController.getExtensionMenu().isVisible()) { - menuBarController.getExtensionMenu().setVisible(true); - } + @Override + public void performLayoutDependendAction(MainLayoutHandler runnable) { + runnable.handle(null, menuToolbarViewController); + layoutActions.add(runnable); } - 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(); - } + @Override + public NotificationPane getNotificationPane() { + return notificationPane; } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/VolumeChangeListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/VolumeChangeListener.java new file mode 100644 index 0000000000000000000000000000000000000000..2d017c45054c6cc0a50273085ea55886c5765d3d --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/VolumeChangeListener.java @@ -0,0 +1,18 @@ +package de.tobias.playpad.viewcontroller.main; + +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; + +public class VolumeChangeListener implements ChangeListener<Number> { + + private IMainViewController mainViewController; + + public VolumeChangeListener(IMainViewController mainViewController) { + this.mainViewController = mainViewController; + } + + @Override + public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { + mainViewController.setGlobalVolume(newValue.doubleValue()); + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperInputDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperInputDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..4028874c48522a6c6ce3c6cda59b2b8d1c376928 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperInputDialog.java @@ -0,0 +1,41 @@ +package de.tobias.playpad.viewcontroller.mapper; + +import java.util.Optional; + +import de.tobias.playpad.action.mapper.KeyboardMapper; +import de.tobias.utils.util.StringUtils; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonType; +import javafx.stage.Stage; + +public class KeyboardMapperInputDialog extends Alert { + + public KeyboardMapperInputDialog(KeyboardMapper mapper) { + super(AlertType.NONE); + + Scene scene = getDialogPane().getScene(); + + scene.setOnKeyPressed(ev -> + { + mapper.setKey(ev.getCode().getName()); + mapper.setCode(ev.getCode()); + }); + scene.setOnKeyReleased(ev -> + { + // Close on Finish (alert.close() does not work) + ((Stage) scene.getWindow()).close(); + }); + scene.setOnKeyTyped(ev -> + { + if (!StringUtils.isStringNotVisable(ev.getCharacter())) { + mapper.setKey(ev.getCharacter().toUpperCase()); + } + }); + } + + public boolean showInputDialog() { + Optional<ButtonType> result = showAndWait(); + return !result.isPresent(); + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperViewController.java index 580f84d0f31c897f9b92d2262839ddf9c4a57fe3..064cf7316bb76069917fa1a9c0ef9f0991576259 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperViewController.java @@ -6,16 +6,11 @@ import de.tobias.playpad.action.mapper.KeyboardMapper; import de.tobias.playpad.action.mapper.Mapper; import de.tobias.playpad.action.mapper.MapperViewController; import de.tobias.utils.util.Localization; -import de.tobias.utils.util.StringUtils; import javafx.event.ActionEvent; import javafx.fxml.FXML; -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.stage.Stage; public class KeyboardMapperViewController extends MapperViewController { @@ -34,10 +29,12 @@ public class KeyboardMapperViewController extends MapperViewController { } @Override - public void hideFeedback() {} + public void hideFeedback() { + } @Override - public void showFeedback() {} + public void showFeedback() { + } private void setLabel() { keyLabel.setText(mapper.getReadableName()); @@ -45,38 +42,24 @@ public class KeyboardMapperViewController extends MapperViewController { @FXML private void mappingButtonHandler(ActionEvent event) { - Alert alert = new Alert(AlertType.NONE); + inputDialog(); + } + + private boolean inputDialog() { + KeyboardMapperInputDialog alert = new KeyboardMapperInputDialog(mapper); alert.setTitle(Localization.getString(Strings.Mapper_Keyboard_Name)); alert.setContentText(Localization.getString(Strings.Info_Mapper_PressKey)); - Scene scene = alert.getDialogPane().getScene(); - - scene.setOnKeyPressed(ev -> - { - mapper.setKey(ev.getCode().getName()); - mapper.setCode(ev.getCode()); - setLabel(); - }); - scene.setOnKeyReleased(ev -> - { - // Close on Finish (alert.close() does not work) - ((Stage) scene.getWindow()).close(); - }); - scene.setOnKeyTyped(ev -> - { - if (!StringUtils.isStringNotVisable(ev.getCharacter())) { - mapper.setKey(ev.getCharacter().toUpperCase()); - setLabel(); - } - }); alert.getButtonTypes().add(ButtonType.CANCEL); alert.initOwner(getWindow()); - alert.showAndWait(); + boolean result = alert.showInputDialog(); + setLabel(); + return result; } @Override - public void showInputMapperUI() { - mappingButton.fire(); + public boolean showInputMapperUI() { + return inputDialog(); } public void setMapper(KeyboardMapper keyboardMapper) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java index a24809d66ebaa5437f350ebd1dc746279eb53599..52d5caca51388b4f65b9ec92f0622ee4da70e479 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java @@ -4,12 +4,12 @@ import javax.sound.midi.MidiMessage; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; -import de.tobias.playpad.action.feedback.DoubleSimpleFeedback; import de.tobias.playpad.action.feedback.FeedbackType; -import de.tobias.playpad.action.feedback.SingleSimpleFeedback; import de.tobias.playpad.action.mapper.Mapper; import de.tobias.playpad.action.mapper.MapperViewController; import de.tobias.playpad.action.mapper.MidiMapper; +import de.tobias.playpad.action.mapper.feedback.DoubleMidiFeedback; +import de.tobias.playpad.action.mapper.feedback.SingleMidiFeedback; import de.tobias.playpad.midi.Midi; import de.tobias.playpad.midi.MidiListener; import de.tobias.playpad.viewcontroller.option.feedback.DoubleFeedbackViewController; @@ -74,9 +74,13 @@ public class MidiMapperViewController extends MapperViewController implements Mi * Current Alert for mapping. */ private Alert alert; + // Hilfsvariable um zu speichern, ob der Input Dialog abgebrochen wurde + private boolean canceled = false; @FXML private void midiInputRecordButtonHandler(ActionEvent event) { + canceled = false; + currentListener = Midi.getInstance().getListener(); Midi.getInstance().setListener(this); @@ -91,6 +95,7 @@ public class MidiMapperViewController extends MapperViewController implements Mi Midi.getInstance().setListener(currentListener); currentListener = null; alert = null; + canceled = true; } }); } @@ -117,8 +122,9 @@ public class MidiMapperViewController extends MapperViewController implements Mi } @Override - public void showInputMapperUI() { - midiInputRecordButton.fire(); + public boolean showInputMapperUI() { + midiInputRecordButtonHandler(null); + return !canceled; } public void setMapper(MidiMapper midiMapper) { @@ -135,9 +141,9 @@ public class MidiMapperViewController extends MapperViewController implements Mi } // add new Elements if (mapper.getFeedbackType() == FeedbackType.SINGLE) { - feedbackController = new SingleFeedbackViewController((SingleSimpleFeedback) mapper.getFeedback(), device.getColors()); + feedbackController = new SingleFeedbackViewController((SingleMidiFeedback) mapper.getFeedback(), device.getColors()); } else if (mapper.getFeedbackType() == FeedbackType.DOUBLE) { - feedbackController = new DoubleFeedbackViewController((DoubleSimpleFeedback) mapper.getFeedback(), device.getColors()); + feedbackController = new DoubleFeedbackViewController((DoubleMidiFeedback) mapper.getFeedback(), device.getColors()); } showFeedback(); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/GeneralTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/GeneralTabViewController.java deleted file mode 100644 index 4bb3bedb665346bac197cd878f182a515083b053..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/GeneralTabViewController.java +++ /dev/null @@ -1,346 +0,0 @@ -package de.tobias.playpad.viewcontroller.option; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.Strings; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.project.Project; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.viewcontroller.SettingsTabViewController; -import de.tobias.playpad.viewcontroller.main.IMainViewController; -import de.tobias.utils.application.ApplicationUtils; -import de.tobias.utils.application.container.PathType; -import de.tobias.utils.ui.ViewController; -import de.tobias.utils.util.Localization; -import de.tobias.utils.util.NumberUtils; -import de.tobias.utils.util.Worker; -import javafx.application.Platform; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.CheckBox; -import javafx.scene.control.Label; -import javafx.scene.control.RadioButton; -import javafx.scene.control.TextField; -import javafx.scene.control.ToggleGroup; -import javafx.stage.DirectoryChooser; -import javafx.stage.Modality; -import javafx.stage.Screen; -import javafx.stage.Stage; - -public class GeneralTabViewController extends SettingsTabViewController { - - private static final String DIGIT_POSITIV = "^[1-9]\\d*$"; - - private Screen mainWindowScreen; - private ViewController parentController; // Für Benachrichtungen - - @FXML private TextField pageCountTextField; - @FXML private TextField columnTextField; - @FXML private TextField rowTextField; - - @FXML private CheckBox liveModeCheckBox; - - @FXML private TextField cacheTextField; - @FXML private Label cacheSizeLabel; - - @FXML private RadioButton pageEnable; - @FXML private RadioButton pageDisable; - @FXML private ToggleGroup pageGroup; - @FXML private RadioButton dragEnable; - @FXML private RadioButton dragDisable; - @FXML private ToggleGroup dragGroup; - @FXML private RadioButton fileEnable; - @FXML private RadioButton fileDisable; - @FXML private ToggleGroup fileGroup; - @FXML private RadioButton settingsEnable; - @FXML private RadioButton settingsDisable; - @FXML private ToggleGroup settingsGroup; - - private boolean changeSettings; - - public GeneralTabViewController(Screen currentScreen, ViewController parentController, boolean activePlayer) { - super("generalTab", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); - this.mainWindowScreen = currentScreen; - this.parentController = parentController; - - if (activePlayer) { - rowTextField.setDisable(true); - columnTextField.setDisable(true); - pageCountTextField.setDisable(true); - } - calcCacheSize(); - } - - @Override - public void init() { - pageCountTextField.textProperty().addListener((a, b, c) -> - { - if (c.matches(DIGIT_POSITIV) && !c.isEmpty()) { - int number = Integer.valueOf(c); - if (number > ProfileSettings.MAX_PAGES) { - pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Zahl zu groß - } else { - pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); // Zahl ok - } - } else { - pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Negativ oder leer - } - }); - - columnTextField.textProperty().addListener((a, b, c) -> - { - if (c.matches(DIGIT_POSITIV) && !c.isEmpty()) { - if (screenValid()) { - columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); // Zahl ok - } else { - columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Zahl zu groß - } - } else { - columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Negativ oder leer - } - }); - - rowTextField.textProperty().addListener((a, b, c) -> - { - if (c.matches(DIGIT_POSITIV) && !c.isEmpty()) { - if (screenValid()) { - rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); // Zahl ok - } else { - rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Zahl zu groß - } - } else { - rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Negativ oder leer - } - }); - - pageGroup = new ToggleGroup(); - pageGroup.getToggles().addAll(pageEnable, pageDisable); - dragGroup = new ToggleGroup(); - dragGroup.getToggles().addAll(dragEnable, dragDisable); - fileGroup = new ToggleGroup(); - fileGroup.getToggles().addAll(fileEnable, fileDisable); - settingsGroup = new ToggleGroup(); - settingsGroup.getToggles().addAll(settingsEnable, settingsDisable); - - liveModeCheckBox.selectedProperty().addListener((a, b, c) -> - { - disableLiveSettings(c); - }); - } - - private void disableLiveSettings(Boolean enableLiveSettings) { - pageEnable.setDisable(!enableLiveSettings); - pageDisable.setDisable(!enableLiveSettings); - dragEnable.setDisable(!enableLiveSettings); - dragDisable.setDisable(!enableLiveSettings); - fileEnable.setDisable(!enableLiveSettings); - fileDisable.setDisable(!enableLiveSettings); - settingsEnable.setDisable(!enableLiveSettings); - settingsDisable.setDisable(!enableLiveSettings); - } - - @FXML - private void cacheChooseHandler(ActionEvent event) { - DirectoryChooser chooser = new DirectoryChooser(); - File folder = chooser.showDialog(getStage()); - if (folder != null) { - Path folderPath = folder.toPath(); - Profile.currentProfile().getProfileSettings().setCachePath(folderPath); - cacheTextField.setText(folderPath.toString()); - } - } - - @FXML - private void cacheResetButtonHandler(ActionEvent event) { - try { - int deleteFiles = 0; - for (Path path : Files.newDirectoryStream(ApplicationUtils.getApplication().getPath(PathType.CACHE))) { - if (Files.isRegularFile(path)) { - try { - Files.delete(path); - deleteFiles++; - } catch (Exception e) { - e.printStackTrace(); - } - } - } - parentController.showInfoMessage(Localization.getString(Strings.Info_Settings_CacheDelete, deleteFiles), - PlayPadMain.stageIcon.get()); - - calcCacheSize(); - } catch (IOException e) { - e.printStackTrace(); - showErrorMessage(Localization.getString(Strings.Error_Settings_CacheClear, e.getLocalizedMessage())); - } - } - - @FXML - private void resetDialogs(ActionEvent event) { - parentController.showInfoMessage(Localization.getString(Strings.Info_Settings_ResetWarning)); - } - - private void calcCacheSize() { - try { - double size = 0; - Path path = Profile.currentProfile().getProfileSettings().getCachePath(); - if (Files.notExists(path)) - Files.createDirectories(path); - - for (Path item : Files.newDirectoryStream(Profile.currentProfile().getProfileSettings().getCachePath())) { - size += Files.size(item); - } - cacheSizeLabel.setText(Localization.getString(Strings.UI_Window_Settings_Gen_CacheSize, NumberUtils.numberToString(size))); - } catch (IOException e) { - e.printStackTrace(); - parentController.showErrorMessage(Localization.getString(Strings.Error_Settings_CacheSize, e.getMessage()), PlayPadMain.stageIcon); - } - } - - private boolean screenValid() { - double width = mainWindowScreen.getVisualBounds().getMaxX() - mainWindowScreen.getVisualBounds().getMinX(); - double height = mainWindowScreen.getVisualBounds().getMaxY() - mainWindowScreen.getVisualBounds().getMinY(); - - GlobalLayout layout = Profile.currentProfile().currentLayout(); - - try { - double neededWidth = layout.getMinWidth(Integer.valueOf(columnTextField.getText())); - double neededHeight = layout.getMinHeight(Integer.valueOf(rowTextField.getText())) + 100; - - if (neededHeight <= height && neededWidth <= width) - return true; - } catch (NumberFormatException e) {} - return false; - } - - @Override - public void loadSettings(Profile profile) { - ProfileSettings profileSettings = profile.getProfileSettings(); - - pageCountTextField.setText(String.valueOf(profileSettings.getPageCount())); - columnTextField.setText(String.valueOf(profileSettings.getColumns())); - rowTextField.setText(String.valueOf(profileSettings.getRows())); - - liveModeCheckBox.setSelected(profileSettings.isLiveMode()); - cacheTextField.setText(profileSettings.getCachePath().toString()); - - if (screenValid()) { - columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); - rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); - } else { - columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); - rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); - } - - if (profileSettings.isLiveModePage() == true) - pageEnable.setSelected(true); - else - pageDisable.setSelected(true); - - if (profileSettings.isLiveModeDrag() == true) - dragEnable.setSelected(true); - else - dragDisable.setSelected(true); - - if (profileSettings.isLiveModeFile() == true) - fileEnable.setSelected(true); - else - fileDisable.setSelected(true); - - if (profileSettings.isLiveModeSettings() == true) - settingsEnable.setSelected(true); - else - settingsDisable.setSelected(true); - - disableLiveSettings(profileSettings.isLiveMode()); - } - - @Override - public void saveSettings(Profile profile) { - ProfileSettings profileSettings = profile.getProfileSettings(); - - int columns = Integer.valueOf(columnTextField.getText()); - int rows = Integer.valueOf(rowTextField.getText()); - int pageCount = Integer.valueOf(pageCountTextField.getText()); - - if (profileSettings.getColumns() != columns || profileSettings.getRows() != rows || profileSettings.getPageCount() != pageCount) - changeSettings = true; - else - changeSettings = false; - - // Copy Settings - profileSettings.setColumns(columns); - profileSettings.setRows(rows); - profileSettings.setPageCount(pageCount); - - 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()); - } - - @Override - public boolean needReload() { - return changeSettings; - } - - @Override - public void reload(Profile profile, 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.getToolbarController().createPageButtons(); - controller.createPadViews(); - controller.showPage(controller.getPage()); - stage.close(); - }); - }); - - } - - @Override - public boolean validSettings() { - if (screenValid()) { - return true; - } else { - double width = mainWindowScreen.getVisualBounds().getMaxX() - mainWindowScreen.getVisualBounds().getMinX(); - double height = mainWindowScreen.getVisualBounds().getMaxY() - mainWindowScreen.getVisualBounds().getMinY(); - - GlobalLayout globalLayout = Profile.currentProfile().currentLayout(); - - int maxCartsX = (int) (width / globalLayout.getPadWidth()); - int maxCartsY = (int) ((height - 100) / globalLayout.getPadHeight()); - parentController.showErrorMessage(Localization.getString(Strings.Error_Profile_SmallScreen, maxCartsX, maxCartsY), - PlayPadMain.stageIcon.orElse(null)); - return false; - } - } - - @Override - public String name() { - return Localization.getString(Strings.UI_Window_Settings_Gen_Title); - } -} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/LayoutTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/LayoutTabViewController.java deleted file mode 100644 index 2077e4e715160998d32974c43b44289433442afc..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/LayoutTabViewController.java +++ /dev/null @@ -1,89 +0,0 @@ -package de.tobias.playpad.viewcontroller.option; - -import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.Strings; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.LayoutConnect; -import de.tobias.playpad.layout.LayoutRegistry; -import de.tobias.playpad.project.Project; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.viewcontroller.GlobalLayoutViewController; -import de.tobias.playpad.viewcontroller.SettingsTabViewController; -import de.tobias.playpad.viewcontroller.cell.DisplayableCell; -import de.tobias.playpad.viewcontroller.main.IMainViewController; -import de.tobias.utils.util.Localization; -import javafx.fxml.FXML; -import javafx.scene.control.ComboBox; -import javafx.scene.layout.VBox; - -public class LayoutTabViewController extends SettingsTabViewController { - - @FXML private VBox layoutContainer; - @FXML private ComboBox<LayoutConnect> layoutTypeComboBox; - private GlobalLayoutViewController globalLayoutViewController; - - public LayoutTabViewController() { - super("layoutTab", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); - - String layoutType = Profile.currentProfile().getProfileSettings().getLayoutType(); - layoutTypeComboBox.setValue(LayoutRegistry.getLayout(layoutType)); - } - - @Override - public void init() { - // Layout - layoutTypeComboBox.getItems().setAll(LayoutRegistry.getValues()); - layoutTypeComboBox.valueProperty().addListener((a, b, c) -> - { - String type = c.getType(); - - Profile.currentProfile().getProfileSettings().setLayoutType(type); - GlobalLayout layout = Profile.currentProfile().getLayout(type); - try { - setLayoutController(c.getGlobalLayoutViewController(layout)); - } catch (Exception e) { - e.printStackTrace(); - showErrorMessage(Localization.getString(Strings.Error_Layout_Load, e.getMessage())); - } - }); - - layoutTypeComboBox.setCellFactory((list) -> new DisplayableCell<>()); - layoutTypeComboBox.setButtonCell(new DisplayableCell<>()); - } - - private void setLayoutController(GlobalLayoutViewController globalLayoutViewController) { - if (this.globalLayoutViewController != null) - layoutContainer.getChildren().remove(this.globalLayoutViewController.getParent()); - - if (globalLayoutViewController != null) { - this.globalLayoutViewController = globalLayoutViewController; - layoutContainer.getChildren().add(globalLayoutViewController.getParent()); - } - } - - @Override - public void loadSettings(Profile profile) {} - - @Override - public void saveSettings(Profile profile) {} - - @Override - public boolean needReload() { - return true; - } - - @Override - public void reload(Profile profile, Project project, IMainViewController controller) { - controller.loadUserCss(); - } - - @Override - public boolean validSettings() { - return true; - } - - @Override - public String name() { - return Localization.getString(Strings.UI_Window_Settings_Layout_Title); - } -} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java index 24c6cfb81e5544f1beb8ac696a4a96555a170cf8..81b5e1992d378e5a8c151cdcf0896b5ee17d0104 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java @@ -7,8 +7,8 @@ import org.controlsfx.control.PopOver.ArrowLocation; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.action.feedback.DisplayableFeedbackColor; -import de.tobias.playpad.action.feedback.DoubleSimpleFeedback; import de.tobias.playpad.action.feedback.FeedbackMessage; +import de.tobias.playpad.action.mapper.feedback.DoubleMidiFeedback; import de.tobias.playpad.action.mididevice.Device; import de.tobias.playpad.midi.Midi; import de.tobias.playpad.view.ColorView; @@ -36,9 +36,9 @@ public class DoubleFeedbackViewController extends ContentViewController { private PopOver colorChooser; - private DoubleSimpleFeedback feedback; + private DoubleMidiFeedback feedback; - public DoubleFeedbackViewController(DoubleSimpleFeedback feedback, DisplayableFeedbackColor[] colors) { + public DoubleFeedbackViewController(DoubleMidiFeedback feedback, DisplayableFeedbackColor[] colors) { super("doubleFeedback", "de/tobias/playpad/assets/view/option/feedback/", PlayPadMain.getUiResourceBundle()); this.feedback = feedback; @@ -89,11 +89,11 @@ public class DoubleFeedbackViewController extends ContentViewController { colorChooser.hide(); if (item instanceof DisplayableFeedbackColor) { if (event.getSource() == colorChooseDefaultButton) { - feedback.setFeedbackDefaultValue(((DisplayableFeedbackColor) item).midiVelocity()); + feedback.setFeedbackDefaultValue(((DisplayableFeedbackColor) item).mapperFeedbackValue()); colorPreviewDefault.setFill(item.getPaint()); setColorChooseButtonColor(item.getPaint(), colorChooseDefaultButton); } else if (event.getSource() == colorChooseEventButton) { - feedback.setFeedbackEventValue(((DisplayableFeedbackColor) item).midiVelocity()); + feedback.setFeedbackEventValue(((DisplayableFeedbackColor) item).mapperFeedbackValue()); colorPreviewEvent.setFill(item.getPaint()); setColorChooseButtonColor(item.getPaint(), colorChooseEventButton); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java index 7a737802e3b7579ce6ea35d480f8cb79356fb002..94cfd8b3228a1e354861e70e34948b09e345036b 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java @@ -8,7 +8,7 @@ import org.controlsfx.control.PopOver.ArrowLocation; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.action.feedback.DisplayableFeedbackColor; import de.tobias.playpad.action.feedback.FeedbackMessage; -import de.tobias.playpad.action.feedback.SingleSimpleFeedback; +import de.tobias.playpad.action.mapper.feedback.SingleMidiFeedback; import de.tobias.playpad.action.mididevice.Device; import de.tobias.playpad.midi.Midi; import de.tobias.playpad.view.ColorView; @@ -32,9 +32,9 @@ public class SingleFeedbackViewController extends ContentViewController { private PopOver colorChooser; - private SingleSimpleFeedback feedback; + private SingleMidiFeedback feedback; - public SingleFeedbackViewController(SingleSimpleFeedback feedback, DisplayableFeedbackColor[] colors) { + public SingleFeedbackViewController(SingleMidiFeedback feedback, DisplayableFeedbackColor[] colors) { super("singleFeedback", "de/tobias/playpad/assets/view/option/feedback/", PlayPadMain.getUiResourceBundle()); this.feedback = feedback; @@ -70,7 +70,7 @@ public class SingleFeedbackViewController extends ContentViewController { colorChooser.hide(); if (item instanceof DisplayableFeedbackColor) { if (event.getSource() == colorChooseDefaultButton) { - feedback.setFeedbackValue(((DisplayableFeedbackColor) item).midiVelocity()); + feedback.setFeedbackValue(((DisplayableFeedbackColor) item).mapperFeedbackValue()); colorPreviewDefault.setFill(item.getPaint()); setColorChooseButtonColor(item.getPaint(), colorChooseDefaultButton); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..e7551ff2c858cff00df4d0e07478cc898948bfec --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java @@ -0,0 +1,177 @@ +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; +import javafx.scene.control.ToggleButton; +import javafx.stage.Stage; +import javafx.stage.Window; + +public class GlobalSettingsViewController extends ViewController implements IGlobalSettingsViewController { + + @FXML private TabPane tabPane; + @FXML private ToggleButton lockedButton; + @FXML private Button finishButton; + + protected List<GlobalSettingsTabViewController> tabs = new ArrayList<>(); + + private Runnable onFinish; + + public GlobalSettingsViewController(Window owner, Runnable onFinish) { + super("globalSettingsView", "de/tobias/playpad/assets/view/option/global/", null, PlayPadMain.getUiResourceBundle()); + this.onFinish = onFinish; + + getStage().initOwner(owner); + + addTab(new GeneralTabViewController(this)); + addTab(new KeysTabViewController()); + addTab(new UpdateTabViewController()); + + // Show Current Settings + loadTabs(); + } + + @Override + public void init() { + // KeyCode + addCloseKeyShortcut(() -> finishButton.fire()); + + finishButton.defaultButtonProperty().bind(finishButton.focusedProperty()); + } + + @Override + public void initStage(Stage stage) { + PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); + + stage.setMinWidth(715); + stage.setMinHeight(700); + stage.setTitle(Localization.getString(Strings.UI_Window_GlobalSettings_Title)); + + Profile.currentProfile().currentLayout().applyCss(getStage()); + } + + /** + * Zeigt die aktuellen Einstellungen für die Tabs an. + */ + private void loadTabs() { + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + + for (GlobalSettingsTabViewController controller : tabs) { + controller.loadSettings(globalSettings); + } + } + + /** + * Speichert die Einstellungen der Tabs. + */ + private void saveTabs() { + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + + for (GlobalSettingsTabViewController controller : tabs) { + controller.saveSettings(globalSettings); + } + + try { + globalSettings.save(); + } catch (Exception e) { + showErrorMessage(Localization.getString(Strings.Error_Profile_Save, e.getLocalizedMessage())); + e.printStackTrace(); + } + } + + public boolean closeRequest() { + return onFinish(); + } + + // Button Listener + @FXML + private void finishButtonHandler(ActionEvent event) { + onFinish(); + getStage().close(); + } + + /** + * Speichert alle Informationen. + * + * @return <code>true</code>Alle Einstellungen sind Valid. + */ + private boolean onFinish() { + for (GlobalSettingsTabViewController controller : tabs) { + if (controller.validSettings() == false) { + return false; + } + } + + 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); + tabPane.getTabs().add(new Tab(controller.name(), controller.getParent())); + } + + public List<GlobalSettingsTabViewController> getTabs() { + return tabs; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..58f00e1ddc268cb85ca0b0abbe8a423682efe2df --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java @@ -0,0 +1,215 @@ +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.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; +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; +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.TableColumn; +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 implements IGlobalReloadTask { + + @FXML private TextField searchTextField; + + @FXML private TableView<Key> table; + @FXML private TableColumn<Key, String> shortcutTableColumn; + @FXML private TableColumn<Key, String> nameTableColumn; + + @FXML private Label nameLabel; + @FXML private Label shortcutLabel; + @FXML private Button newShortcutButton; + @FXML private Button deleteButton; + + private Key currentKey; + private ObservableList<Key> keys = FXCollections.observableArrayList(); + + public KeysTabViewController() { + super("keysTab", "de/tobias/playpad/assets/view/option/global/", PlayPadMain.getUiResourceBundle()); + } + + @Override + public void init() { + shortcutTableColumn.setCellValueFactory(param -> + { + return param.getValue().displayProperty(); + }); + nameTableColumn.setCellValueFactory(param -> + { + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + return new SimpleStringProperty(globalSettings.getKeyCollection().getName(param.getValue().getId())); + }); + + table.getSelectionModel().selectedItemProperty().addListener((a, b, c) -> + { + setDetailView(c); + }); + searchTextField.textProperty().addListener((a, b, c) -> search()); + + table.setRowFactory(tv -> + { + TableRow<Key> row = new TableRow<>(); + row.setOnMouseClicked(event -> + { + if (event.getClickCount() == 2 && (!row.isEmpty())) { + setDetailView(row.getItem()); + showNewKeyBindingDialog(); + } + }); + return row; + }); + + } + + private void setDetailView(Key key) { + currentKey = key; + + if (key != null) { + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + + String name = globalSettings.getKeyCollection().getName(key.getId()); + nameLabel.setText(name); + + shortcutLabel.setText(key.toString()); + newShortcutButton.setDisable(false); + } else { + nameLabel.setText(""); + shortcutLabel.setText(""); + newShortcutButton.setDisable(true); + } + } + + @FXML + void newShortcutButtonHandler(ActionEvent event) { + showNewKeyBindingDialog(); + } + + @FXML + void deleteHandler(ActionEvent event) { + if (currentKey != null) { + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + globalSettings.getKeyCollection().removeKeyBinding(currentKey); + } + } + + private void showNewKeyBindingDialog() { + Alert alert = new Alert(AlertType.NONE); + alert.setContentText(Localization.getString(Strings.UI_Settings_Alert_NewKeyShortcut_Text)); + Scene scene = alert.getDialogPane().getScene(); + + scene.setOnKeyPressed(ev -> + { + if (ev.getCode().isModifierKey()) { + return; + } + + boolean macCondition = ev.getCode().isLetterKey() || ev.getCode().isKeypadKey() || ev.getCode().isDigitKey() + || ev.getCode().isFunctionKey() || ev.getCode() == KeyCode.PERIOD || ev.getCode() == KeyCode.COMMA; + + if (OS.isWindows() || macCondition) { + String key = ev.getCode().getName(); + + Key newKey = new Key(currentKey.getId(), key, ev.isControlDown(), ev.isAltDown(), ev.isMetaDown(), ev.isShiftDown()); + + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + KeyCollection keyCollection = globalSettings.getKeyCollection(); + + boolean conflict = keyCollection.keysConflict(newKey); + if (!conflict) { + keyCollection.editKey(newKey); + + shortcutLabel.setText(currentKey.toString()); + Platform.runLater(() -> ((Stage) scene.getWindow()).close()); + } else { + 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(); + } + + @Override + public void loadSettings(GlobalSettings settings) { + keys.setAll(settings.getKeyCollection().getKeys()); + table.setItems(keys); + } + + @Override + public void saveSettings(GlobalSettings settings) { + // Passiert beim Drücken von Tasten automatisch + } + + @Override + public boolean needReload() { + return true; + } + + @Override + 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 + public boolean validSettings() { + return true; + } + + @Override + public String name() { + return Localization.getString(Strings.UI_Window_Settings_Keys_Title); + } + + private void search() { + FilteredList<Key> filteredData = new FilteredList<>(keys, s -> true); + String search = searchTextField.getText(); + if (search == null || search.length() == 0) { + filteredData.setPredicate(s -> true); + } else { + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + filteredData.setPredicate(s -> globalSettings.getKeyCollection().getName(s.getId()).toLowerCase().startsWith(search.toLowerCase())); + } + table.setItems(filteredData); + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java similarity index 76% rename from PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java index 0bf463e78c590218e2303fee471d4475a84323ca..bc7aeddd7ec4750cb9aae7cd1b5ec6614a03a483 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java @@ -1,19 +1,20 @@ -package de.tobias.playpad.viewcontroller.option; +package de.tobias.playpad.viewcontroller.option.global; import java.io.IOException; 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.settings.ProfileSettings; import de.tobias.playpad.update.Updatable; import de.tobias.playpad.update.UpdateChannel; import de.tobias.playpad.update.UpdateRegistery; import de.tobias.playpad.update.Updates; -import de.tobias.playpad.viewcontroller.SettingsTabViewController; import de.tobias.playpad.viewcontroller.cell.EnumCell; import de.tobias.playpad.viewcontroller.cell.UpdateCell; import de.tobias.playpad.viewcontroller.dialog.UpdaterDialog; +import de.tobias.playpad.viewcontroller.option.GlobalSettingsTabViewController; import de.tobias.utils.application.ApplicationInfo; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.util.Localization; @@ -29,7 +30,7 @@ import javafx.scene.control.ListView; import javafx.scene.control.ProgressIndicator; import javafx.scene.image.ImageView; -public class UpdateTabViewController extends SettingsTabViewController { +public class UpdateTabViewController extends GlobalSettingsTabViewController { @FXML private Label currentVersionLabel; @@ -49,10 +50,11 @@ public class UpdateTabViewController extends SettingsTabViewController { private Label placeholderLabel; public UpdateTabViewController() { - super("updateTab", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); + super("updateTab", "de/tobias/playpad/assets/view/option/global/", PlayPadMain.getUiResourceBundle()); - ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); - updateChannelComboBox.setValue(profileSettings.getUpdateChannel()); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + + updateChannelComboBox.setValue(globalSettings.getUpdateChannel()); openUpdateList.getItems().setAll(UpdateRegistery.getAvailableUpdates()); updateButton.setDisable(openUpdateList.getItems().isEmpty()); @@ -71,7 +73,8 @@ public class UpdateTabViewController extends SettingsTabViewController { updateChannelComboBox.valueProperty().addListener((a, b, c) -> { - Profile.currentProfile().getProfileSettings().setUpdateChannel(c); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + globalSettings.setUpdateChannel(c); }); infoCLabel.setGraphic(new ImageView("de/tobias/playpad/assets/files/class_obj.png")); @@ -98,7 +101,8 @@ public class UpdateTabViewController extends SettingsTabViewController { Worker.runLater(() -> { // Search for updates - UpdateRegistery.lookupUpdates(profile.getProfileSettings().getUpdateChannel()); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + UpdateRegistery.lookupUpdates(globalSettings.getUpdateChannel()); Platform.runLater(() -> { @@ -116,6 +120,9 @@ public class UpdateTabViewController extends SettingsTabViewController { UpdaterDialog dialog = new UpdaterDialog(getStage()); dialog.show(); + GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); + settings.setIgnoreUpdate(false); + Worker.runLater(() -> { try { @@ -128,13 +135,13 @@ public class UpdateTabViewController extends SettingsTabViewController { // Settings Tab Methods @Override - public void loadSettings(Profile profile) { - automaticSearchCheckBox.setSelected(profile.getProfileSettings().isAutoUpdate()); + public void loadSettings(GlobalSettings profile) { + automaticSearchCheckBox.setSelected(profile.isAutoUpdate()); } @Override - public void saveSettings(Profile profile) { - profile.getProfileSettings().setAutoUpdate(automaticSearchCheckBox.isSelected()); + public void saveSettings(GlobalSettings profile) { + profile.setAutoUpdate(automaticSearchCheckBox.isSelected()); } @Override diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/LayoutPadTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/DesignPadTabViewController.java similarity index 66% rename from PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/LayoutPadTabViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/DesignPadTabViewController.java index 0ddb4f3d2626a4f1059208d6740b3f7ab9c5478f..c5919f6a08310f994cc2561203bfe1c5dcc5f819 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/LayoutPadTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/DesignPadTabViewController.java @@ -8,11 +8,13 @@ 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.layout.CartLayout; -import de.tobias.playpad.layout.LayoutRegistry; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.DesignConnect; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.viewcontroller.CartLayoutViewController; +import de.tobias.playpad.viewcontroller.CartDesignViewController; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.util.Localization; @@ -20,20 +22,20 @@ import javafx.fxml.FXML; import javafx.scene.control.CheckBox; import javafx.scene.layout.VBox; -public class LayoutPadTabViewController extends PadSettingsTabViewController { +public class DesignPadTabViewController extends PadSettingsTabViewController { @FXML private VBox layoutContainer; @FXML private CheckBox enableLayoutCheckBox; - private CartLayoutViewController layoutViewController; + private CartDesignViewController layoutViewController; private Pad pad; - public LayoutPadTabViewController(Pad pad) { + public DesignPadTabViewController(Pad pad) { super("layoutTab", "de/tobias/playpad/assets/view/option/pad/", PlayPadMain.getUiResourceBundle()); this.pad = pad; } - private void setLayoutController(CartLayoutViewController cartLayoutViewController) { + private void setLayoutController(CartDesignViewController cartLayoutViewController) { if (layoutViewController != null) layoutContainer.getChildren().remove(layoutViewController.getParent()); @@ -47,12 +49,13 @@ public class LayoutPadTabViewController extends PadSettingsTabViewController { public void init() { enableLayoutCheckBox.selectedProperty().addListener((a, b, c) -> { - if (c && !pad.isCustomLayout()) { + PadSettings padSettings = pad.getPadSettings(); + if (c && !padSettings.isCustomLayout()) { try { - pad.setCustomLayout(true); + padSettings.setCustomLayout(true); String layoutType = Profile.currentProfile().getProfileSettings().getLayoutType(); - CartLayout layout = pad.getLayout(layoutType); + CartDesign layout = padSettings.getLayout(layoutType); layout.copyGlobalLayout(Profile.currentProfile().getLayout(layoutType)); setLayoutViewController(pad); @@ -60,8 +63,8 @@ public class LayoutPadTabViewController extends PadSettingsTabViewController { showErrorMessage(Localization.getString(Strings.Error_Standard_Gen, e.getLocalizedMessage())); e.printStackTrace(); } - } else if (!c && pad.isCustomLayout()) { - pad.setCustomLayout(false); + } else if (!c && padSettings.isCustomLayout()) { + padSettings.setCustomLayout(false); setLayoutController(null); } }); @@ -74,8 +77,10 @@ public class LayoutPadTabViewController extends PadSettingsTabViewController { @Override public void loadSettings(Pad pad) { - enableLayoutCheckBox.setSelected(pad.isCustomLayout()); - if (pad.isCustomLayout()) { + PadSettings padSettings = pad.getPadSettings(); + + enableLayoutCheckBox.setSelected(padSettings.isCustomLayout()); + if (padSettings.isCustomLayout()) { setLayoutViewController(pad); } } @@ -83,10 +88,14 @@ public class LayoutPadTabViewController extends PadSettingsTabViewController { private void setLayoutViewController(Pad pad) { try { String layoutType = Profile.currentProfile().getProfileSettings().getLayoutType(); - CartLayout layout = pad.getLayout(layoutType); + CartDesign layout = pad.getPadSettings().getLayout(layoutType); - CartLayoutViewController controller = LayoutRegistry.getLayout(layoutType).getCartLayoutViewController(layout); + DesignConnect component = PlayPadPlugin.getRegistryCollection().getDesigns().getComponent(layoutType); + CartDesignViewController controller = component.getCartDesignViewController(layout); setLayoutController(controller); + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); showErrorMessage(Localization.getString(Strings.Error_Layout_Load, e.getMessage())); @@ -103,7 +112,7 @@ public class LayoutPadTabViewController extends PadSettingsTabViewController { Mapping activeMapping = Profile.currentProfile().getMappings().getActiveMapping(); List<CartAction> actions = activeMapping.getActions(CartActionConnect.TYPE); // Update die Mapper der CartAction - actions.stream().filter(item -> item.getCart() == pad.getIndex()) + actions.stream().filter(action -> action.getPad() != null).filter(action -> action.getPad().getIndex() == pad.getIndex()) .forEach(item -> item.initFeedback(pad.getProject(), mainViewController)); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java index b42cd88481eed915acead2e5623f385b0d95b012..ea172c2a24e297fcb88402e25dfb85b56c3c983b 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java @@ -3,6 +3,7 @@ package de.tobias.playpad.viewcontroller.option.pad; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.TimeMode; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; @@ -36,7 +37,7 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { public GeneralPadTabViewController(Pad pad) { super("generalTab", "de/tobias/playpad/assets/view/option/pad/", PlayPadMain.getUiResourceBundle()); this.pad = pad; - + if (pad.getStatus() == PadStatus.PLAY || pad.getStatus() == PadStatus.PAUSE) { deleteButton.setDisable(true); } @@ -45,17 +46,19 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { @Override public void init() { // Init Listener - volumeListener = (a, b, c) -> pad.setVolume(c.doubleValue() / 100.0); + volumeListener = (a, b, c) -> pad.getPadSettings().setVolume(c.doubleValue() / 100.0); volumeSlider.valueProperty().addListener(volumeListener); customTimeDisplayCheckBox.selectedProperty().addListener((a, b, c) -> { + PadSettings padSettings = pad.getPadSettings(); + timeDisplayComboBox.setDisable(!c); - if (c && !pad.isCustomTimeMode()) - pad.setTimeMode(TimeMode.REST); - else if (b && pad.isCustomTimeMode()) - pad.setTimeMode(null); + if (c && !padSettings.isCustomTimeMode()) + padSettings.setTimeMode(TimeMode.REST); + else if (b && padSettings.isCustomTimeMode()) + padSettings.setTimeMode(null); }); timeDisplayComboBox.getItems().addAll(TimeMode.values()); @@ -70,25 +73,29 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { @Override public void loadSettings(Pad pad) { + PadSettings padSettings = pad.getPadSettings(); + // Bindings titleTextField.textProperty().bindBidirectional(pad.nameProperty()); - repeatCheckBox.selectedProperty().bindBidirectional(pad.loopProperty()); - timeDisplayComboBox.valueProperty().bindBidirectional(pad.timeModeProperty()); + repeatCheckBox.selectedProperty().bindBidirectional(padSettings.loopProperty()); + timeDisplayComboBox.valueProperty().bindBidirectional(padSettings.timeModeProperty()); - volumeSlider.setValue(pad.getVolume() * 100); + volumeSlider.setValue(padSettings.getVolume() * 100); // is Custom TimeMode Actvie - customTimeDisplayCheckBox.setSelected(pad.isCustomTimeMode()); - if (!pad.isCustomTimeMode()) { + customTimeDisplayCheckBox.setSelected(padSettings.isCustomTimeMode()); + if (!padSettings.isCustomTimeMode()) { timeDisplayComboBox.setDisable(true); } } @Override public void saveSettings(Pad pad) { + PadSettings padSettings = pad.getPadSettings(); + titleTextField.textProperty().unbindBidirectional(pad.nameProperty()); - repeatCheckBox.selectedProperty().unbindBidirectional(pad.loopProperty()); - timeDisplayComboBox.valueProperty().unbindBidirectional(pad.timeModeProperty()); + repeatCheckBox.selectedProperty().unbindBidirectional(padSettings.loopProperty()); + timeDisplayComboBox.valueProperty().unbindBidirectional(padSettings.timeModeProperty()); } // Listener 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 8a8c69521c07984f3713b192bb7664c7d72c80f4..468c689d0beae454669725b3c0e072e37c87c4a1 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java @@ -1,15 +1,20 @@ package de.tobias.playpad.viewcontroller.option.pad; +import java.nio.file.Path; import java.util.ArrayList; import java.util.List; 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.PadContentRegistry; import de.tobias.playpad.pad.PadStatus; +import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.conntent.PadContentConnect; -import de.tobias.playpad.pad.conntent.PadContentRegistry; -import de.tobias.playpad.pad.conntent.UnkownPadContentException; +import de.tobias.playpad.pad.conntent.path.MultiPathContent; +import de.tobias.playpad.pad.conntent.path.SinglePathContent; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.IPadSettingsViewController; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; @@ -17,9 +22,14 @@ import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.fxml.FXML; +import javafx.scene.Parent; import javafx.scene.control.Button; +import javafx.scene.control.Control; +import javafx.scene.control.MenuButton; +import javafx.scene.control.MenuItem; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; +import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; import javafx.stage.Window; @@ -30,6 +40,9 @@ public class PadSettingsViewController extends ViewController implements IPadSet @FXML private TabPane tabPane; protected List<PadSettingsTabViewController> tabs = new ArrayList<>(); + private Control pathLookupButton; + private PathLookupListener pathLookupListener; + @FXML private Button finishButton; public PadSettingsViewController(Pad pad, Window owner) { @@ -37,22 +50,28 @@ public class PadSettingsViewController extends ViewController implements IPadSet this.pad = pad; addTab(new GeneralPadTabViewController(pad)); - addTab(new LayoutPadTabViewController(pad)); + addTab(new DesignPadTabViewController(pad)); addTab(new PlayerPadTabViewController(pad)); addTab(new TriggerPadTabViewController(pad)); if (pad.getContent() != null) { try { // Get Pad Type specific tab - PadContentConnect padContentConnect = PadContentRegistry.getPadContentConnect(pad.getContent().getType()); + String type = pad.getContent().getType(); + PadContentRegistry registry = PlayPadPlugin.getRegistryCollection().getPadContents(); + + PadContentConnect padContentConnect = registry.getComponent(type); PadSettingsTabViewController contentTab = padContentConnect.getSettingsViewController(pad); + if (contentTab != null) addTab(contentTab); - } catch (UnkownPadContentException e) { + } catch (NoSuchComponentException e) { e.printStackTrace(); } } + setupPathLookupButton(); + getStage().initOwner(owner); // Show Current Settings @@ -60,6 +79,53 @@ public class PadSettingsViewController extends ViewController implements IPadSet setTitle(pad); } + private void setupPathLookupButton() { + pathLookupListener = new PathLookupListener(this); + + if (pad.getContent() != null) { + PadContent content = pad.getContent(); + // nur EIN Path + if (content instanceof SinglePathContent) { + Button button = new Button(PlayPadMain.getUiResourceBundle().getString("padSettings.button.path")); + + // Referenz auf das Model + Path path = ((SinglePathContent) content).getPath(); + button.setUserData(path); + + button.setOnAction(pathLookupListener); + + // Setzt globales Feld + pathLookupButton = button; + } else if (content instanceof MultiPathContent) { + MenuButton button = new MenuButton(PlayPadMain.getUiResourceBundle().getString("padSettings.button.path")); + List<Path> paths = ((MultiPathContent) content).getPaths(); + + for (Path path : paths) { + MenuItem item = new MenuItem(path.getFileName().toString()); + button.getItems().add(item); + + // Referenz auf das Model + item.setUserData(path); + + item.setOnAction(pathLookupListener); + } + + // Setzt globales Feld + pathLookupButton = button; + } + + // Hüge Path Button zum Root Container hinzu. + Parent parent = getParent(); + if (parent instanceof AnchorPane && pathLookupButton != null) { + AnchorPane anchorPane = (AnchorPane) parent; + anchorPane.getChildren().add(pathLookupButton); + + AnchorPane.setLeftAnchor(pathLookupButton, 14.0); + AnchorPane.setBottomAnchor(pathLookupButton, 14.0); + } + } + } + private void setTitle(Pad pad) { if (pad.getStatus() != PadStatus.EMPTY) { getStage().setTitle(Localization.getString(Strings.UI_Window_PadSettings_Title, pad.getIndexReadable(), pad.getName())); @@ -122,5 +188,6 @@ public class PadSettingsViewController extends ViewController implements IPadSet for (PadSettingsTabViewController controller : tabs) { controller.saveSettings(pad); } + getStage().close(); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java new file mode 100644 index 0000000000000000000000000000000000000000..c397e4e397e471a2bd578e654599b4d6f901cdd0 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java @@ -0,0 +1,50 @@ +package de.tobias.playpad.viewcontroller.option.pad; + +import java.awt.Desktop; +import java.io.IOException; +import java.nio.file.Path; + +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.Strings; +import de.tobias.utils.ui.Alertable; +import de.tobias.utils.util.Localization; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.control.Button; +import javafx.scene.control.MenuItem; + +public class PathLookupListener implements EventHandler<ActionEvent> { + + private Alertable alertable; + + public PathLookupListener(Alertable alertable) { + this.alertable = alertable; + } + + public void handle(ActionEvent event) { + Object source = event.getSource(); + if (source instanceof Button) { + // single path + Object userData = ((Button) source).getUserData(); + if (userData instanceof Path) { + showPath((Path) userData); + } + } else if (source instanceof MenuItem) { + // multiple path + Object userData = ((MenuItem) source).getUserData(); + if (userData instanceof Path) { + showPath((Path) userData); + } + } + } + + private void showPath(Path path) { + try { + Desktop.getDesktop().browse(path.getParent().toUri()); + } catch (IOException e) { + 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/pad/PlayerPadTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java index 4cae57b156b833e7b8eb572b7830a9c0a8bbed94..8757543768ae05b1b536979e26c6cdc1d0960322 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java @@ -3,6 +3,7 @@ package de.tobias.playpad.viewcontroller.option.pad; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.settings.Fade; import de.tobias.playpad.settings.Warning; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; @@ -42,22 +43,26 @@ public class PlayerPadTabViewController extends PadSettingsTabViewController { customFadeCheckBox.selectedProperty().addListener((a, b, c) -> { fadeContainer.setDisable(!c); - if (c && !pad.isCustomFade()) - pad.setFade(new Fade()); - else if (!c && pad.isCustomFade()) - pad.setFade(null); + PadSettings padSettings = pad.getPadSettings(); + + if (c && !padSettings.isCustomFade()) + padSettings.setFade(new Fade()); + else if (!c && padSettings.isCustomFade()) + padSettings.setFade(null); if (c) - fadeViewController.setFade(pad.getFade()); + fadeViewController.setFade(padSettings.getFade()); }); warningEnableCheckBox.selectedProperty().addListener((a, b, c) -> { warningFeedbackContainer.setDisable(!c); - if (c && !pad.isCustomWarning()) - pad.setWarning(new Warning()); - else if (!c && pad.isCustomWarning()) - pad.setWarning(null); + PadSettings padSettings = pad.getPadSettings(); + + if (c && !padSettings.isCustomWarning()) + padSettings.setWarning(new Warning()); + else if (!c && padSettings.isCustomWarning()) + padSettings.setWarning(null); if (c) warningFeedbackViewController.setPadWarning(pad); @@ -71,16 +76,18 @@ public class PlayerPadTabViewController extends PadSettingsTabViewController { @Override public void loadSettings(Pad pad) { - if (pad.isCustomFade()) - fadeViewController.setFade(pad.getFade()); + PadSettings padSettings = pad.getPadSettings(); + + if (padSettings.isCustomFade()) + fadeViewController.setFade(padSettings.getFade()); - customFadeCheckBox.setSelected(pad.isCustomFade()); - if (!pad.isCustomFade()) { + customFadeCheckBox.setSelected(padSettings.isCustomFade()); + if (!padSettings.isCustomFade()) { fadeContainer.setDisable(true); } - warningEnableCheckBox.setSelected(pad.isCustomWarning()); - if (!pad.isCustomWarning()) { + warningEnableCheckBox.setSelected(padSettings.isCustomWarning()); + if (!padSettings.isCustomWarning()) { warningFeedbackContainer.setDisable(true); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/TriggerPadTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/TriggerPadTabViewController.java index 6f28cfd46f0e3ae97de4df72a7c61ba9bfe6f708..49df6c486600731271687aaf3075bfdea243f686 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/TriggerPadTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/TriggerPadTabViewController.java @@ -39,7 +39,7 @@ public class TriggerPadTabViewController extends PadSettingsTabViewController im } private void createTreeView() { - HashMap<TriggerPoint, Trigger> triggers = pad.getTriggers(); + HashMap<TriggerPoint, Trigger> triggers = pad.getPadSettings().getTriggers(); TreeItem<TriggerUIWrapper> rootItem = new TreeItem<>(); // Sort the tpyes for the treeview diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerPointViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerPointViewController.java index 6c4ab5728c7f15b77240f073901720eea70380ee..04a53006c8bda7d22cb25f7b958cbc8336f0d917 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerPointViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerPointViewController.java @@ -3,9 +3,10 @@ package de.tobias.playpad.viewcontroller.option.pad.trigger; import java.util.Set; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.tigger.TriggerItem; import de.tobias.playpad.tigger.TriggerItemConnect; -import de.tobias.playpad.tigger.TriggerRegistry; import de.tobias.playpad.trigger.TriggerUIWrapper; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontAwesomeType; @@ -34,51 +35,59 @@ public class TriggerPointViewController extends ContentViewController { @Override public void init() { - Set<String> types = TriggerRegistry.getTypes(); + Set<String> types = PlayPadPlugin.getRegistryCollection().getTriggerItems().getTypes(); types.stream().sorted().forEach(item -> { - Button button = new Button(TriggerRegistry.getTriggerConnect(item).toString(), new FontIcon(FontAwesomeType.PLUS_CIRCLE)); - button.setContentDisplay(ContentDisplay.TOP); - button.setPrefWidth(150); - - button.setOnAction(e -> - { - TriggerItemConnect connect = TriggerRegistry.getTriggerConnect(item); - TriggerItem triggerItem = connect.newInstance(triggerWrapper.getTrigger()); - - triggerWrapper.addItem(triggerItem); - showTriggerItem(triggerItem); - }); - buttonBox.getChildren().add(button); + try { + TriggerItemConnect conntect = PlayPadPlugin.getRegistryCollection().getTriggerItems().getComponent(item); + Button button = new Button(conntect.toString(), new FontIcon(FontAwesomeType.PLUS_CIRCLE)); + button.setContentDisplay(ContentDisplay.TOP); + button.setPrefWidth(150); + + button.setOnAction(e -> + { + TriggerItem triggerItem = conntect.newInstance(triggerWrapper.getTrigger()); + + triggerWrapper.addItem(triggerItem); + showTriggerItem(triggerItem); + }); + buttonBox.getChildren().add(button); + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } }); } private void showTriggerItem(TriggerItem item) { - TriggerItemConnect connect = TriggerRegistry.getTriggerConnect(item.getType()); - - VBox itemBox = new VBox(14); - ContentViewController contentViewController = connect.getSettingsController(item); - if (contentViewController != null) { - itemBox.getChildren().add(contentViewController.getParent()); - - ContentViewController timeViewController = new TriggerTimeViewController(item); - itemBox.getChildren().add(timeViewController.getParent()); - - Button deleteButton = new Button("", new FontIcon(FontAwesomeType.TRASH)); - HBox hbox = new HBox(itemBox, deleteButton); - hbox.setSpacing(14); - - VBox rootBox = new VBox(14.0, hbox, new Separator()); - - itemView.getChildren().addAll(rootBox); - - deleteButton.setOnAction((e) -> - { - triggerWrapper.removeItem(item); - itemView.getChildren().removeAll(rootBox); - }); - -// HBox.setHgrow(itemBox, Priority.ALWAYS); + try { + TriggerItemConnect connect = PlayPadPlugin.getRegistryCollection().getTriggerItems().getComponent(item.getType()); + + VBox itemBox = new VBox(14); + ContentViewController contentViewController = connect.getSettingsController(item); + if (contentViewController != null) { + itemBox.getChildren().add(contentViewController.getParent()); + + ContentViewController timeViewController = new TriggerTimeViewController(item); + itemBox.getChildren().add(timeViewController.getParent()); + + Button deleteButton = new Button("", new FontIcon(FontAwesomeType.TRASH)); + HBox hbox = new HBox(itemBox, deleteButton); + hbox.setSpacing(14); + + VBox rootBox = new VBox(14.0, hbox, new Separator()); + + itemView.getChildren().addAll(rootBox); + + deleteButton.setOnAction((e) -> + { + triggerWrapper.removeItem(item); + itemView.getChildren().removeAll(rootBox); + }); + } + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/AudioTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java similarity index 57% rename from PlayWall/src/de/tobias/playpad/viewcontroller/option/AudioTabViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java index 5e0c3bd36672fa2d417d967a630e3163b1e928d5..e83f9a002ea0c3e33e757e3d006526d0b062a5b4 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/AudioTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java @@ -1,30 +1,33 @@ -package de.tobias.playpad.viewcontroller.option; +package de.tobias.playpad.viewcontroller.option.profile; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.audio.AudioRegistry; 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.SettingsTabViewController; +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 SettingsTabViewController { +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) { - super("audioTab", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); + super("audioTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); if (playerActive) { audioTypeComboBox.setDisable(true); @@ -36,8 +39,11 @@ public class AudioTabViewController extends SettingsTabViewController { public void init() { ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); - // Audio - audioTypeComboBox.getItems().addAll(AudioRegistry.getAudioSystems().keySet()); + // Audio Classes + AudioRegistry audioHandlerRegistry = PlayPadPlugin.getRegistryCollection().getAudioHandlers(); + audioTypeComboBox.getItems().addAll(audioHandlerRegistry.getTypes()); + + // Listener for selection audioTypeComboBox.getSelectionModel().selectedItemProperty().addListener((a, b, c) -> { if (b != null && c != null) @@ -56,9 +62,16 @@ public class AudioTabViewController extends SettingsTabViewController { audioUserInfoSettings.getChildren().clear(); - audioViewController = AudioRegistry.getAudioSystems().get(classID).getAudioViewController(); - if (audioViewController != null) { - audioUserInfoSettings.getChildren().add(audioViewController.getParent()); + try { + AudioRegistry audioHandlerRegistry = PlayPadPlugin.getRegistryCollection().getAudioHandlers(); + audioViewController = audioHandlerRegistry.getComponent(classID).getAudioHandlerSettingsViewController(); + + if (audioViewController != null) { + audioUserInfoSettings.getChildren().add(audioViewController.getParent()); + } + } catch (NoSuchComponentException e) { + e.printStackTrace(); + // TODO Errorhandling } } @@ -89,11 +102,17 @@ public class AudioTabViewController extends SettingsTabViewController { } @Override - public void reload(Profile profile, Project project, IMainViewController controller) { - Worker.runLater(() -> - { - project.getPads().values().forEach(pad -> pad.loadContent()); - }); + 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 new file mode 100644 index 0000000000000000000000000000000000000000..d0585f047370d9990842adf8841c03fa03fe450e --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java @@ -0,0 +1,110 @@ +package de.tobias.playpad.viewcontroller.option.profile; + +import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.Strings; +import de.tobias.playpad.design.GlobalDesign; +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 implements IProfileReloadTask { + + @FXML private VBox layoutContainer; + @FXML private ComboBox<DesignConnect> layoutTypeComboBox; + private GlobalDesignViewController globalLayoutViewController; + + public DesignTabViewController() { + super("layoutTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); + + String layoutType = Profile.currentProfile().getProfileSettings().getLayoutType(); + try { + layoutTypeComboBox.setValue(PlayPadPlugin.getRegistryCollection().getDesigns().getComponent(layoutType)); + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + public void init() { + // Layout + layoutTypeComboBox.getItems().setAll(PlayPadPlugin.getRegistryCollection().getDesigns().getComponents()); + layoutTypeComboBox.valueProperty().addListener((a, b, c) -> + { + String type = c.getType(); + + Profile.currentProfile().getProfileSettings().setLayoutType(type); + GlobalDesign layout = Profile.currentProfile().getLayout(type); + try { + setLayoutController(c.getGlobalDesignViewController(layout)); + } catch (Exception e) { + e.printStackTrace(); + showErrorMessage(Localization.getString(Strings.Error_Layout_Load, e.getMessage())); + } + }); + + layoutTypeComboBox.setCellFactory((list) -> new DisplayableCell<>()); + layoutTypeComboBox.setButtonCell(new DisplayableCell<>()); + } + + private void setLayoutController(GlobalDesignViewController globalLayoutViewController) { + if (this.globalLayoutViewController != null) + layoutContainer.getChildren().remove(this.globalLayoutViewController.getParent()); + + if (globalLayoutViewController != null) { + this.globalLayoutViewController = globalLayoutViewController; + layoutContainer.getChildren().add(globalLayoutViewController.getParent()); + } + } + + @Override + public void loadSettings(Profile profile) { + } + + @Override + public void saveSettings(Profile profile) { + } + + @Override + public boolean needReload() { + return true; + } + + @Override + 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 + public boolean validSettings() { + return true; + } + + @Override + public String name() { + return Localization.getString(Strings.UI_Window_Settings_Layout_Title); + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..406d947c691833217248ecd7e64f507ec7658425 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java @@ -0,0 +1,202 @@ +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.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; +import de.tobias.utils.util.Localization; +import de.tobias.utils.util.NumberUtils; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; +import javafx.scene.control.RadioButton; +import javafx.scene.control.TextField; +import javafx.scene.control.ToggleGroup; +import javafx.stage.DirectoryChooser; + +public class GeneralTabViewController extends GlobalSettingsTabViewController { + + @FXML private CheckBox liveModeCheckBox; + + @FXML private TextField cacheTextField; + @FXML private Label cacheSizeLabel; + + @FXML private RadioButton pageEnable; + @FXML private RadioButton pageDisable; + @FXML private ToggleGroup pageGroup; + @FXML private RadioButton dragEnable; + @FXML private RadioButton dragDisable; + @FXML private ToggleGroup dragGroup; + @FXML private RadioButton fileEnable; + @FXML private RadioButton fileDisable; + @FXML private ToggleGroup fileGroup; + @FXML private RadioButton settingsEnable; + @FXML private RadioButton settingsDisable; + @FXML private ToggleGroup settingsGroup; + + private boolean changeSettings; + + private Alertable alertable; + + public GeneralTabViewController(Alertable alertable) { + super("generalTab", "de/tobias/playpad/assets/view/option/global/", PlayPadMain.getUiResourceBundle()); + this.alertable = alertable; + + calcCacheSize(); + } + + @Override + public void init() { + pageGroup = new ToggleGroup(); + pageGroup.getToggles().addAll(pageEnable, pageDisable); + dragGroup = new ToggleGroup(); + dragGroup.getToggles().addAll(dragEnable, dragDisable); + fileGroup = new ToggleGroup(); + fileGroup.getToggles().addAll(fileEnable, fileDisable); + settingsGroup = new ToggleGroup(); + settingsGroup.getToggles().addAll(settingsEnable, settingsDisable); + + liveModeCheckBox.selectedProperty().addListener((a, b, c) -> + { + disableLiveSettings(c); + }); + } + + private void disableLiveSettings(Boolean enableLiveSettings) { + pageEnable.setDisable(!enableLiveSettings); + pageDisable.setDisable(!enableLiveSettings); + dragEnable.setDisable(!enableLiveSettings); + dragDisable.setDisable(!enableLiveSettings); + fileEnable.setDisable(!enableLiveSettings); + fileDisable.setDisable(!enableLiveSettings); + settingsEnable.setDisable(!enableLiveSettings); + settingsDisable.setDisable(!enableLiveSettings); + } + + @FXML + private void cacheChooseHandler(ActionEvent event) { + DirectoryChooser chooser = new DirectoryChooser(); + File folder = chooser.showDialog(getStage()); + if (folder != null) { + Path folderPath = folder.toPath(); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + globalSettings.setCachePath(folderPath); + cacheTextField.setText(folderPath.toString()); + } + } + + @FXML + private void cacheResetButtonHandler(ActionEvent event) { + try { + int deleteFiles = 0; + for (Path path : Files.newDirectoryStream(ApplicationUtils.getApplication().getPath(PathType.CACHE))) { + if (Files.isRegularFile(path)) { + try { + Files.delete(path); + deleteFiles++; + } catch (Exception e) { + e.printStackTrace(); + } + } + } + alertable.showInfoMessage(Localization.getString(Strings.Info_Settings_CacheDelete, deleteFiles), PlayPadMain.stageIcon.get()); + + calcCacheSize(); + } catch (IOException e) { + e.printStackTrace(); + showErrorMessage(Localization.getString(Strings.Error_Settings_CacheClear, e.getLocalizedMessage())); + } + } + + @FXML + private void resetDialogs(ActionEvent event) { + alertable.showInfoMessage(Localization.getString(Strings.Info_Settings_ResetWarning)); + } + + private void calcCacheSize() { + try { + double size = 0; + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + Path path = globalSettings.getCachePath(); + if (Files.notExists(path)) + Files.createDirectories(path); + + 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(); + alertable.showErrorMessage(Localization.getString(Strings.Error_Settings_CacheSize, e.getMessage()), PlayPadMain.stageIcon); + } + } + + @Override + public void loadSettings(GlobalSettings settings) { + + liveModeCheckBox.setSelected(settings.isLiveMode()); + cacheTextField.setText(settings.getCachePath().toString()); + + if (settings.isLiveModePage() == true) + pageEnable.setSelected(true); + else + pageDisable.setSelected(true); + + if (settings.isLiveModeDrag() == true) + dragEnable.setSelected(true); + else + dragDisable.setSelected(true); + + if (settings.isLiveModeFile() == true) + fileEnable.setSelected(true); + else + fileDisable.setSelected(true); + + if (settings.isLiveModeSettings() == true) + settingsEnable.setSelected(true); + else + settingsDisable.setSelected(true); + + disableLiveSettings(settings.isLiveMode()); + } + + @Override + 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 + public boolean needReload() { + return changeSettings; + } + + @Override + public boolean validSettings() { + return true; + } + + @Override + public String name() { + return Localization.getString(Strings.UI_Window_Settings_Gen_Title); + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/MappingTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java similarity index 69% rename from PlayWall/src/de/tobias/playpad/viewcontroller/option/MappingTabViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java index 4b44d1f425920b252a755cc9c0ad766cc0be477a..f1fe20a9a9946fd2a2b116faa07548bcbdde439a 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/MappingTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java @@ -1,29 +1,33 @@ -package de.tobias.playpad.viewcontroller.option; +package de.tobias.playpad.viewcontroller.option.profile; import java.util.List; import java.util.Set; import java.util.stream.Collectors; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.action.Action; import de.tobias.playpad.action.ActionConnect; import de.tobias.playpad.action.ActionDisplayable; -import de.tobias.playpad.action.ActionRegistery; import de.tobias.playpad.action.ActionType; import de.tobias.playpad.action.Mapping; 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.SettingsTabViewController; 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; @@ -32,7 +36,7 @@ import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.scene.layout.VBox; -public class MappingTabViewController extends SettingsTabViewController implements IMappingTabViewController { +public class MappingTabViewController extends ProfileSettingsTabViewController implements IMappingTabViewController, IProfileReloadTask { @FXML private ComboBox<Mapping> mappingComboBox; @FXML private Button editMappingsButton; @@ -46,7 +50,7 @@ public class MappingTabViewController extends SettingsTabViewController implemen private Mapping mapping; public MappingTabViewController() { - super("mapping", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); + super("mapping", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); } @Override @@ -83,7 +87,7 @@ public class MappingTabViewController extends SettingsTabViewController implemen private TreeItem<ActionDisplayable> createTreeView(Mapping mapping) { TreeItem<ActionDisplayable> rootItem = new TreeItem<>(); - Set<String> types = ActionRegistery.getTypes(); + Set<String> types = PlayPadPlugin.getRegistryCollection().getActions().getTypes(); List<String> sortedTypes = types.stream().sorted().collect(Collectors.toList()); // Sort the tpyes for the treeview @@ -95,12 +99,17 @@ public class MappingTabViewController extends SettingsTabViewController implemen } private void createTreeViewForActionType(Mapping mapping, TreeItem<ActionDisplayable> rootItem, List<String> sortedTypes, ActionType type) { - for (String tpye : sortedTypes) { - List<Action> actions = mapping.getActionsOfType(tpye); - ActionConnect actionConnect = ActionRegistery.getActionConnect(tpye); - if (actionConnect.geActionType() == type) { - TreeItem<ActionDisplayable> item = actionConnect.getTreeViewForActions(actions, mapping); - rootItem.getChildren().add(item); + for (String id : sortedTypes) { + List<Action> actions = mapping.getActionsOfType(id); + try { + ActionConnect actionConnect = PlayPadPlugin.getRegistryCollection().getActions().getComponent(id); + if (actionConnect.geActionType() == type) { + TreeItem<ActionDisplayable> item = actionConnect.getTreeViewForActions(actions, mapping); + rootItem.getChildren().add(item); + } + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } } @@ -133,7 +142,9 @@ public class MappingTabViewController extends SettingsTabViewController implemen } else { detailView.getChildren().remove(mapperOverviewViewController.getParent()); } - } catch (Exception e) {} + } catch (Exception e) { + e.printStackTrace(); + } } // Tab Utils @@ -145,7 +156,8 @@ public class MappingTabViewController extends SettingsTabViewController implemen } @Override - public void saveSettings(Profile profile) {} + public void saveSettings(Profile profile) { + } @Override public boolean needReload() { @@ -153,14 +165,24 @@ public class MappingTabViewController extends SettingsTabViewController implemen } @Override - public void reload(Profile profile, Project project, IMainViewController controller) { - controller.applyColorsToMappers(); - - 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/MidiTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java similarity index 86% rename from PlayWall/src/de/tobias/playpad/viewcontroller/option/MidiTabViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java index 0c6e45c2e1c371685cd8d0ba349f51a78f3eaddb..efedbd16a858c01b42deb8a4b802b7f3ac8483ef 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/MidiTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.viewcontroller.option; +package de.tobias.playpad.viewcontroller.option.profile; import javax.sound.midi.MidiDevice.Info; import javax.sound.midi.MidiUnavailableException; @@ -6,11 +6,9 @@ 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.SettingsTabViewController; -import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -18,7 +16,7 @@ import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; import javafx.scene.layout.AnchorPane; -public class MidiTabViewController extends SettingsTabViewController { +public class MidiTabViewController extends ProfileSettingsTabViewController { @FXML private AnchorPane rootPane; @@ -26,7 +24,7 @@ public class MidiTabViewController extends SettingsTabViewController { @FXML private ComboBox<String> deviceComboBox; public MidiTabViewController() { - super("midiTab", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); + super("midiTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); Info[] data = Midi.getMidiDevices(); // Gerät anzeigen - Doppelte weg @@ -112,11 +110,6 @@ public class MidiTabViewController extends SettingsTabViewController { 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/PlayerTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java similarity index 80% rename from PlayWall/src/de/tobias/playpad/viewcontroller/option/PlayerTabViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java index 94713e8a15dba9fae93ac619173bdf5eebfd416a..a903758d2d2b638087854631368945c007643c19 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/PlayerTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java @@ -1,22 +1,24 @@ -package de.tobias.playpad.viewcontroller.option; +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.SettingsTabViewController; 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; import de.tobias.utils.util.Localization; import javafx.fxml.FXML; +import javafx.scene.control.CheckBox; import javafx.scene.control.ComboBox; import javafx.scene.layout.VBox; -public class PlayerTabViewController extends SettingsTabViewController { +public class PlayerTabViewController extends ProfileSettingsTabViewController { + + // Modus + @FXML private CheckBox playerModus; // Player @FXML private VBox warningFeedbackContainer; @@ -24,7 +26,7 @@ public class PlayerTabViewController extends SettingsTabViewController { @FXML private ComboBox<TimeMode> timeDisplayComboBox; public PlayerTabViewController() { - super("playerTab", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); + super("playerTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); // Player FadeViewController fadeViewController = new FadeViewController(); @@ -52,6 +54,7 @@ public class PlayerTabViewController extends SettingsTabViewController { public void loadSettings(Profile profile) { ProfileSettings profileSettings = profile.getProfileSettings(); + playerModus.setSelected(profile.getProfileSettings().isMultiplePlayer()); timeDisplayComboBox.setValue(profileSettings.getPlayerTimeDisplayMode()); } @@ -60,6 +63,7 @@ public class PlayerTabViewController extends SettingsTabViewController { ProfileSettings profileSettings = profile.getProfileSettings(); // Player + profileSettings.setMultiplePlayer(playerModus.isSelected()); profileSettings.setPlayerTimeDisplayMode(timeDisplayComboBox.getValue()); } @@ -68,9 +72,6 @@ public class PlayerTabViewController extends SettingsTabViewController { 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/SettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java similarity index 51% rename from PlayWall/src/de/tobias/playpad/viewcontroller/option/SettingsViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java index 8dc5d9b1b85b7e8a3a1f60e77ac049717285483f..5d37af62d3c566b6d4f338ed640dc0eb79ddcc04 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/SettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java @@ -1,24 +1,33 @@ -package de.tobias.playpad.viewcontroller.option; +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; import de.tobias.playpad.midi.Midi; -import de.tobias.playpad.pad.conntent.PadContentRegistry; -import de.tobias.playpad.pad.conntent.UnkownPadContentException; +import de.tobias.playpad.pad.conntent.PadContentConnect; 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.ISettingsViewController; -import de.tobias.playpad.viewcontroller.SettingsTabViewController; +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; @@ -27,39 +36,41 @@ import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.Window; -public class SettingsViewController extends ViewController implements ISettingsViewController { +public class ProfileSettingsViewController extends ViewController implements IProfileSettingsViewController { @FXML private TabPane tabPane; @FXML private ToggleButton lockedButton; @FXML private Button finishButton; - protected List<SettingsTabViewController> tabs = new ArrayList<>(); + protected List<ProfileSettingsTabViewController> tabs = new ArrayList<>(); + + private Runnable onFinish; - public SettingsViewController(Midi midiHandler, Screen currentScreen, Window owner, Project project) { - super("settingsView", "de/tobias/playpad/assets/view/option/", null, PlayPadMain.getUiResourceBundle()); + public ProfileSettingsViewController(Midi midiHandler, Screen currentScreen, Window owner, Project project, Runnable onFinish) { + 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(currentScreen, this, activePlayer)); addTab(new MappingTabViewController()); addTab(new MidiTabViewController()); - addTab(new LayoutTabViewController()); + addTab(new DesignTabViewController()); addTab(new PlayerTabViewController()); // Custom Tabs - Content Types - for (String type : PadContentRegistry.getTypes()) { + for (String type : PlayPadPlugin.getRegistryCollection().getPadContents().getTypes()) { try { - SettingsTabViewController controller = PadContentRegistry.getPadContentConnect(type).getSettingsTabViewController(activePlayer); + PadContentConnect component = PlayPadPlugin.getRegistryCollection().getPadContents().getComponent(type); + ProfileSettingsTabViewController controller = component.getSettingsTabViewController(activePlayer); if (controller != null) { addTab(controller); } - } catch (UnkownPadContentException e) { + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block e.printStackTrace(); } } - addTab(new UpdateTabViewController()); - getStage().initOwner(owner); // Show Current Settings @@ -107,7 +118,7 @@ public class SettingsViewController extends ViewController implements ISettingsV */ private void loadTabs() { Profile profile = Profile.currentProfile(); - for (SettingsTabViewController controller : tabs) { + for (ProfileSettingsTabViewController controller : tabs) { controller.loadSettings(profile); } } @@ -117,7 +128,7 @@ public class SettingsViewController extends ViewController implements ISettingsV */ private void saveTabs() { Profile profile = Profile.currentProfile(); - for (SettingsTabViewController controller : tabs) { + for (ProfileSettingsTabViewController controller : tabs) { controller.saveSettings(profile); } @@ -146,17 +157,55 @@ public class SettingsViewController extends ViewController implements ISettingsV * @return <code>true</code>Alle Einstellungen sind Valid. */ private boolean onFinish() { - for (SettingsTabViewController controller : tabs) { + for (ProfileSettingsTabViewController controller : tabs) { if (controller.validSettings() == false) { return false; } } saveTabs(); - updateData(); // Reload MainViewController Settings // TODO Rewrite + 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. * @@ -167,8 +216,13 @@ public class SettingsViewController extends ViewController implements ISettingsV tabPane.setDisable(isLocked); } - public void addTab(SettingsTabViewController controller) { + @Override + public void addTab(ProfileSettingsTabViewController controller) { tabs.add(controller); tabPane.getTabs().add(new Tab(controller.name(), controller.getParent())); } + + public List<ProfileSettingsTabViewController> getTabs() { + return tabs; + } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..24fe811955fbb7b5e7e7d5d3d1bc00ec5b09bcfb --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java @@ -0,0 +1,209 @@ +package de.tobias.playpad.viewcontroller.option.project; + +import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PseudoClasses; +import de.tobias.playpad.Strings; +import de.tobias.playpad.design.GlobalDesign; +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 javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.fxml.FXML; +import javafx.scene.control.TextField; +import javafx.stage.Screen; + +public class GeneralTabViewController extends ProjectSettingsTabViewController implements IProjectReloadTask { + + private static final String DIGIT_POSITIV = "^[1-9]\\d*$"; + + private Screen mainWindowScreen; + private Alertable parentController; // Für Benachrichtungen + + @FXML private TextField pageCountTextField; + @FXML private TextField columnTextField; + @FXML private TextField rowTextField; + + public GeneralTabViewController(Screen currentScreen, Alertable parentController, boolean activePlayer) { + super("generalTab", "de/tobias/playpad/assets/view/option/project/", PlayPadMain.getUiResourceBundle()); + + this.mainWindowScreen = currentScreen; + this.parentController = parentController; + + if (activePlayer) { + rowTextField.setDisable(true); + columnTextField.setDisable(true); + pageCountTextField.setDisable(true); + } + + } + + @Override + public void init() { + pageCountTextField.textProperty().addListener((a, b, c) -> + { + if (c.matches(DIGIT_POSITIV) && !c.isEmpty()) { + int number = Integer.valueOf(c); + if (number > ProjectSettings.MAX_PAGES) { + pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Zahl zu groß + } else { + pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); // Zahl ok + } + } else { + pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Negativ oder leer + } + }); + + columnTextField.textProperty().addListener((a, b, c) -> + { + if (c.matches(DIGIT_POSITIV) && !c.isEmpty()) { + if (screenValid()) { + columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); // Zahl ok + } else { + columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Zahl zu groß + } + } else { + columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Negativ oder leer + } + }); + + rowTextField.textProperty().addListener((a, b, c) -> + { + if (c.matches(DIGIT_POSITIV) && !c.isEmpty()) { + if (screenValid()) { + rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); // Zahl ok + } else { + rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Zahl zu groß + } + } else { + rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Negativ oder leer + } + }); + } + + private boolean screenValid() { + double width = mainWindowScreen.getVisualBounds().getMaxX() - mainWindowScreen.getVisualBounds().getMinX(); + double height = mainWindowScreen.getVisualBounds().getMaxY() - mainWindowScreen.getVisualBounds().getMinY(); + + GlobalDesign layout = Profile.currentProfile().currentLayout(); + + try { + double neededWidth = layout.getMinWidth(Integer.valueOf(columnTextField.getText())); + double neededHeight = layout.getMinHeight(Integer.valueOf(rowTextField.getText())) + 100; + + if (neededHeight <= height && neededWidth <= width) + return true; + } catch (NumberFormatException e) { + } + return false; + } + + @Override + public void loadSettings(ProjectSettings settings) { + pageCountTextField.setText(String.valueOf(settings.getPageCount())); + columnTextField.setText(String.valueOf(settings.getColumns())); + rowTextField.setText(String.valueOf(settings.getRows())); + + if (screenValid()) { + columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); + rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); + } else { + columnTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); + rowTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); + } + + } + + private boolean changeSettings = false; + + @Override + public void saveSettings(ProjectSettings settings) { + int columns = Integer.valueOf(columnTextField.getText()); + int rows = Integer.valueOf(rowTextField.getText()); + int pageCount = Integer.valueOf(pageCountTextField.getText()); + + if (settings.getColumns() != columns || settings.getRows() != rows || settings.getPageCount() != pageCount) + changeSettings = true; + else + changeSettings = false; + + // Copy Settings + settings.setColumns(columns); + settings.setRows(rows); + settings.setPageCount(pageCount); + } + + @Override + public boolean needReload() { + 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(() -> + // { + // + // }); + // }); + // } + + @Override + public boolean validSettings() { + if (screenValid()) { + return true; + } else { + double width = mainWindowScreen.getVisualBounds().getMaxX() - mainWindowScreen.getVisualBounds().getMinX(); + double height = mainWindowScreen.getVisualBounds().getMaxY() - mainWindowScreen.getVisualBounds().getMinY(); + + GlobalDesign globalLayout = Profile.currentProfile().currentLayout(); + + int maxCartsX = (int) (width / globalLayout.getPadWidth()); + int maxCartsY = (int) ((height - 100) / globalLayout.getPadHeight()); + parentController.showErrorMessage(Localization.getString(Strings.Error_Profile_SmallScreen, maxCartsX, maxCartsY), + PlayPadMain.stageIcon.orElse(null)); + return false; + } + } + + @Override + public String name() { + 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 new file mode 100644 index 0000000000000000000000000000000000000000..6d284bb6d5a013c3a4bdb4fac3ff82cc37c8de99 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java @@ -0,0 +1,167 @@ +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; +import javafx.scene.control.ToggleButton; +import javafx.stage.Screen; +import javafx.stage.Stage; +import javafx.stage.Window; + +public class ProjectSettingsViewController extends ViewController implements IProjectSettingsViewController { + + @FXML private TabPane tabPane; + @FXML private ToggleButton lockedButton; + @FXML private Button finishButton; + + protected List<ProjectSettingsTabViewController> tabs = new ArrayList<>(); + 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.project = project; + + boolean activePlayer = project.hasActivePlayers(); + + addTab(new GeneralTabViewController(currentScreen, this, activePlayer)); + addTab(new PathsTabViewController()); + + getStage().initOwner(owner); + + // Show Current Settings + loadTabs(project.getSettings()); + } + + @Override + public void init() { + // KeyCode + addCloseKeyShortcut(() -> finishButton.fire()); + + finishButton.defaultButtonProperty().bind(finishButton.focusedProperty()); + } + + @Override + public void initStage(Stage stage) { + PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); + + stage.setMinWidth(715); + stage.setMinHeight(500); + stage.setTitle(Localization.getString(Strings.UI_Window_ProjectSettings_Title)); + + Profile.currentProfile().currentLayout().applyCss(getStage()); + } + + /** + * Zeigt die aktuellen Einstellungen für die Tabs an. + */ + private void loadTabs(ProjectSettings settings) { + for (ProjectSettingsTabViewController controller : tabs) { + controller.loadSettings(settings); + } + } + + /** + * Speichert die Einstellungen der Tabs. + */ + private void saveTabs(ProjectSettings settings) { + for (ProjectSettingsTabViewController controller : tabs) { + controller.saveSettings(settings); + } + } + + @Override + public boolean closeRequest() { + return onFinish(); + } + + // Button Listener + @FXML + private void finishButtonHandler(ActionEvent event) { + onFinish(); + getStage().close(); + } + + /** + * Speichert alle Informationen. + * + * @return <code>true</code>Alle Einstellungen sind Valid. + */ + private boolean onFinish() { + for (ProjectSettingsTabViewController controller : tabs) { + if (controller.validSettings() == false) { + return false; + } + } + + 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); + tabPane.getTabs().add(new Tab(controller.name(), controller.getParent())); + } + + public List<ProjectSettingsTabViewController> getTabs() { + return tabs; + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java index e8a1676c7f154541899cef2b78ddd8337070ffb8..abbbf607050a5f6e31bef72c3a5fabdffb387c21 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java @@ -1,23 +1,23 @@ package de.tobias.playpad.viewcontroller.pad; import java.io.File; +import java.io.IOException; import java.util.Collection; import java.util.Set; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.Pad; +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.conntent.PadContentRegistry; -import de.tobias.playpad.pad.conntent.UnkownPadContentException; import de.tobias.playpad.pad.drag.PadDragMode; -import de.tobias.playpad.pad.drag.PadDragModeRegistery; +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.playpad.view.PadView; import de.tobias.utils.util.FileUtils; import javafx.scene.SnapshotParameters; import javafx.scene.image.WritableImage; @@ -26,13 +26,14 @@ import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.scene.input.MouseEvent; import javafx.scene.input.TransferMode; +import javafx.scene.layout.Pane; import javafx.scene.paint.Color; public class PadDragListener { private static final String REGEX = "[0-9]+"; - private Pad pad; - final private PadView view; + private Pad sourcePad; + final private Pane view; private static boolean dndMode; private static Project project; @@ -40,15 +41,15 @@ public class PadDragListener { private PadDragOptionView padHud; private FileDragOptionView fileHud; - public PadDragListener(Pad pad, PadView view) { - this.pad = pad; - this.view = view; + public PadDragListener(Pad pad, IPadView view) { + this.sourcePad = pad; + this.view = view.getRootNode(); // Drag and Drop - view.setOnDragOver(event -> dragOver(event)); - view.setOnDragExited(event -> dragExited()); - view.setOnDragDropped(event -> dragDropped(event)); - view.setOnDragDetected(event -> dragDetacted(event)); + this.view.setOnDragOver(event -> dragOver(event)); + this.view.setOnDragExited(event -> dragExited()); + this.view.setOnDragDropped(event -> dragDropped(event)); + this.view.setOnDragDetected(event -> dragDetacted(event)); } private void dragOver(DragEvent event) { @@ -58,19 +59,21 @@ public class PadDragListener { if (event.getGestureSource() != this && event.getDragboard().hasFiles()) { if (event.getDragboard().getFiles().get(0).isFile()) { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - if (pad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getPlayedPlayers() > 0) { - PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); + + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + + if (sourcePad.getProject() != null) { + if (globalSettings.isLiveMode() && globalSettings.isLiveModeFile() && sourcePad.getProject().getActivePlayers() > 0) { return; } } - + File file = event.getDragboard().getFiles().get(0); // Build In Filesupport try { - Set<PadContentConnect> connects = PadContentRegistry.getPadContentConnectsForFile(file.toPath()); + PadContentRegistry registry = PlayPadPlugin.getRegistryCollection().getPadContents(); + Set<PadContentConnect> connects = registry.getPadContentConnectsForFile(file.toPath()); if (!connects.isEmpty()) { if (fileHud == null) { @@ -81,7 +84,7 @@ public class PadDragListener { event.acceptTransferModes(TransferMode.LINK); return; } - } catch (UnkownPadContentException e) { + } catch (NoSuchComponentException e) { e.printStackTrace(); } } @@ -90,9 +93,9 @@ public class PadDragListener { // Drag and Drop von Pads if (event.getDragboard().hasString() && event.getDragboard().getString().trim().matches(REGEX)) { int padID = Integer.valueOf(event.getDragboard().getString()); - if (padID != view.getController().getPad().getIndex()) { + if (padID != sourcePad.getIndex()) { - Collection<PadDragMode> connects = PadDragModeRegistery.getValues(); + Collection<PadDragMode> connects = PlayPadPlugin.getRegistryCollection().getDragModes().getComponents(); if (!connects.isEmpty()) { if (padHud == null) { @@ -125,17 +128,25 @@ public class PadDragListener { PadContentConnect connect = fileHud.getSelectedConnect(); if (connect != null) { - PadContent content = pad.getContent(); - if (pad.getContent() == null || !pad.getContent().getType().equals(connect.getType())) { - content = connect.newInstance(pad); + PadContent content = sourcePad.getContent(); + if (sourcePad.getContent() == null || !sourcePad.getContent().getType().equals(connect.getType())) { + content = connect.newInstance(sourcePad); } - content.handlePath(file.toPath()); - this.pad.setContent(content); - this.pad.setName(FileUtils.getFilenameWithoutExtention(file.toPath().getFileName())); + try { + content.handlePath(file.toPath()); + } catch (NoSuchComponentException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.sourcePad.setContent(content); + this.sourcePad.setName(FileUtils.getFilenameWithoutExtention(file.toPath().getFileName())); - view.setPreviewContent(pad); - view.addDefaultButton(pad); + if (sourcePad.getController() != null) { + IPadView padView = sourcePad.getController().getView(); + padView.setContentView(sourcePad); + padView.addDefaultElement(sourcePad); + } } } @@ -143,7 +154,7 @@ public class PadDragListener { int padID = Integer.valueOf(db.getString()); PadDragMode mode = padHud.getSelectedPadDragMode(); - mode.handle(padID, pad.getIndex(), project); + mode.handle(padID, sourcePad.getIndex(), project); padHud.hide(); PlayPadPlugin.getImplementation().getMainViewController() @@ -156,14 +167,14 @@ public class PadDragListener { private void dragDetacted(MouseEvent event) { if (dndMode) { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - if (pad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeDrag() && pad.getProject().getPlayedPlayers() > 0) { - PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); + GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); + + if (sourcePad.getProject() != null) { + if (globalSettings.isLiveMode() && globalSettings.isLiveModeDrag() && sourcePad.getProject().getActivePlayers() > 0) { return; } } - + Dragboard dragboard = view.startDragAndDrop(TransferMode.MOVE); SnapshotParameters parameters = new SnapshotParameters(); @@ -180,19 +191,26 @@ public class PadDragListener { dragboard.setDragView(snapshot); ClipboardContent content = new ClipboardContent(); - content.putString(String.valueOf(pad.getIndex())); + content.putString(String.valueOf(sourcePad.getIndex())); dragboard.setContent(content); event.consume(); } } + /** + * Aktiviert den Drag And Drop Modus für Kacheln. Diese Methode muss vom Menu / KeyShortcut aufgerufen werden. + * + * @param dndMode + * <code>true</code> Aktiv + */ public static void setDndMode(boolean dndMode) { PadDragListener.dndMode = dndMode; } + @Deprecated public void setPad(Pad pad) { - this.pad = pad; + this.sourcePad = pad; } public static void setProject(Project project) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadViewController.java index 1f112d73fd2f853ef34bd99a3fe91cb7ed3d676e..47372327084c09e2b17c49f972f6956a1e89f1f6 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadViewController.java @@ -2,40 +2,32 @@ package de.tobias.playpad.viewcontroller.pad; import java.io.File; import java.nio.file.Path; -import java.util.Set; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.TimeMode; -import de.tobias.playpad.pad.conntent.Durationable; import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.conntent.PadContentConnect; -import de.tobias.playpad.pad.conntent.PadContentRegistry; -import de.tobias.playpad.pad.conntent.UnkownPadContentException; +import de.tobias.playpad.pad.conntent.play.Durationable; +import de.tobias.playpad.pad.listener.IPadPositionListener; import de.tobias.playpad.pad.listener.PadContentListener; 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.IPadViewController; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.view.FileDragOptionView; import de.tobias.playpad.view.PadView; import de.tobias.playpad.viewcontroller.IPadView; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.pad.PadSettingsViewController; -import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.util.FileUtils; -import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.event.EventHandler; -import javafx.scene.Node; -import javafx.stage.FileChooser; -import javafx.stage.FileChooser.ExtensionFilter; import javafx.stage.Stage; import javafx.util.Duration; @@ -59,11 +51,12 @@ public class PadViewController implements EventHandler<ActionEvent>, IPadViewCon public PadViewController() { view = new PadView(this); - padLockedListener = new PadLockedListener(this); + // TODO Disable this + /*padLockedListener = new PadLockedListener(this); padStatusListener = new PadStatusListener(this); padContentListener = new PadContentListener(this); padDurationListener = new PadDurationListener(this); - padPositionListener = new PadPositionListener(this); + padPositionListener = new PadPositionListener(this);*/ // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController erzeugt ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); @@ -109,55 +102,55 @@ public class PadViewController implements EventHandler<ActionEvent>, IPadViewCon } private void onNew(ActionEvent event) { - ProfileSettings settings = Profile.currentProfile().getProfileSettings(); - if (pad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getPlayedPlayers() > 0) { - PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); - return; - } - } - - FileChooser chooser = new FileChooser(); - - // File Extension - ExtensionFilter extensionFilter = new ExtensionFilter(Localization.getString(Strings.File_Filter_Media), - PadContentRegistry.getSupportedFileTypes()); - chooser.getExtensionFilters().add(extensionFilter); - - // Last Folder - Object openFolder = ApplicationUtils.getApplication().getUserDefaults().getData(OPEN_FOLDER); - if (openFolder != null) { - File folder = new File(openFolder.toString()); - chooser.setInitialDirectory(folder); - } - - File file = chooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow()); - if (file != null) { - Path path = file.toPath(); - - try { - Set<PadContentConnect> connects = PadContentRegistry.getPadContentConnectsForFile(file.toPath()); - if (!connects.isEmpty()) { - if (connects.size() > 1) { - FileDragOptionView hud = new FileDragOptionView(view); - hud.showDropOptions(connects, connect -> - { - if (connect != null) { - setNewPadContent(file, path, connect); - hud.hide(); - } - }); - } else { - PadContentConnect connect = connects.iterator().next(); - setNewPadContent(file, path, connect); - } - } - } catch (UnkownPadContentException e) { - e.printStackTrace(); - } - - ApplicationUtils.getApplication().getUserDefaults().setData(OPEN_FOLDER, path.getParent().toString()); - } +// ProfileSettings settings = Profile.currentProfile().getProfileSettings(); +// if (pad.getProject() != null) { +// if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getPlayedPlayers() > 0) { +// PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); +// return; +// } +// } +// +// FileChooser chooser = new FileChooser(); +// +// // File Extension +// ExtensionFilter extensionFilter = new ExtensionFilter(Localization.getString(Strings.File_Filter_Media), +// PadContentRegistry.getSupportedFileTypes()); +// chooser.getExtensionFilters().add(extensionFilter); +// +// // Last Folder +// Object openFolder = ApplicationUtils.getApplication().getUserDefaults().getData(OPEN_FOLDER); +// if (openFolder != null) { +// File folder = new File(openFolder.toString()); +// chooser.setInitialDirectory(folder); +// } +// +// File file = chooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow()); +// if (file != null) { +// Path path = file.toPath(); +// +// try { +// Set<PadContentConnect> connects = PadContentRegistry.getPadContentConnectsForFile(file.toPath()); +// if (!connects.isEmpty()) { +// if (connects.size() > 1) { +// FileDragOptionView hud = new FileDragOptionView(view); +// hud.showDropOptions(connects, connect -> +// { +// if (connect != null) { +// setNewPadContent(file, path, connect); +// hud.hide(); +// } +// }); +// } else { +// PadContentConnect connect = connects.iterator().next(); +// setNewPadContent(file, path, connect); +// } +// } +// } catch (UnkownPadContentException e) { +// e.printStackTrace(); +// } +// +// ApplicationUtils.getApplication().getUserDefaults().setData(OPEN_FOLDER, path.getParent().toString()); +// } } private void setNewPadContent(File file, Path path, PadContentConnect connect) { @@ -167,7 +160,12 @@ public class PadViewController implements EventHandler<ActionEvent>, IPadViewCon this.pad.setContent(content); } - content.handlePath(file.toPath()); + try { + content.handlePath(file.toPath()); + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } this.pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); } @@ -244,7 +242,7 @@ public class PadViewController implements EventHandler<ActionEvent>, IPadViewCon @Override public void connectPad() { - pad.setController(this); +// pad.setController(this); TODO try { // Settings @@ -266,7 +264,7 @@ public class PadViewController implements EventHandler<ActionEvent>, IPadViewCon padContentListener.changed(null, null, pad.getContent()); // Add Duration listener padStatusListener.changed(null, null, pad.getStatus()); - padDragListener = new PadDragListener(pad, view); +// padDragListener = new PadDragListener(pad, view); TODO } catch (Exception e) { e.printStackTrace(); } @@ -387,7 +385,7 @@ public class PadViewController implements EventHandler<ActionEvent>, IPadViewCon return padStatusListener; } - public PadPositionListener getPadPositionListener() { + public IPadPositionListener getPadPositionListener() { return padPositionListener; } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/settings/WarningFeedbackViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/settings/WarningFeedbackViewController.java index f09d2e2dd0cc36f3cdc27f4a0588b961eb18445c..ff0bb390135736ffb001579e52180aa04c562ab8 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/settings/WarningFeedbackViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/settings/WarningFeedbackViewController.java @@ -48,14 +48,14 @@ public class WarningFeedbackViewController extends ContentViewController { } public void setPadWarning(Pad pad) { - if (pad.getWarning() != null) { - warningFeedbackTimeSlider.setValue(pad.getWarning().getTime().toSeconds()); + if (pad.getPadSettings().getWarning() != null) { + warningFeedbackTimeSlider.setValue(pad.getPadSettings().getWarning().getTime().toSeconds()); setTimeLabel(); } warningFeedbackTimeSlider.valueProperty().addListener((a, b, c) -> { - pad.getWarning().setTime(Duration.seconds(c.doubleValue())); + pad.getPadSettings().getWarning().setTime(Duration.seconds(c.doubleValue())); }); } } diff --git a/PlayWallCore/.classpath b/PlayWallCore/.classpath index 717dd3f2a9568f193245b8c860c84e659a991d04..a6fa9547a624843a634dba5d8d42da36ce69f661 100644 --- a/PlayWallCore/.classpath +++ b/PlayWallCore/.classpath @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry excluding="**/.DS_Store|**/.gitignore" kind="src" path="src"/> + <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry combineaccessrules="false" kind="src" path="/libUtils"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Plugins"/> @@ -9,5 +10,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/YML"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JLayer"/> <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Json"/> + <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/PlayWallCore/src/de/tobias/playpad/Displayable.java b/PlayWallCore/src/de/tobias/playpad/Displayable.java index 5f5499a10c85d22d2ae3b9e364223d4ae6ba6bc8..232003e4486219ce97106c3d4abfac96c9d015cc 100644 --- a/PlayWallCore/src/de/tobias/playpad/Displayable.java +++ b/PlayWallCore/src/de/tobias/playpad/Displayable.java @@ -14,6 +14,8 @@ public interface Displayable { /** * Optional Method for a displayable cell + * + * @return Einstellungen für dieses Objetkt. */ public default ContentViewController getSettingsViewController() { return null; diff --git a/PlayWallCore/src/de/tobias/playpad/PlayPad.java b/PlayWallCore/src/de/tobias/playpad/PlayPad.java index 877bd5d97fc07a4e84b89911fa0c063e8663033c..7326cfbbde2f9e11be3ef46f1bb3670131f0eb8b 100644 --- a/PlayWallCore/src/de/tobias/playpad/PlayPad.java +++ b/PlayWallCore/src/de/tobias/playpad/PlayPad.java @@ -7,6 +7,7 @@ import java.util.Optional; import de.tobias.playpad.plugin.PadListener; import de.tobias.playpad.plugin.SettingsListener; import de.tobias.playpad.plugin.WindowListener; +import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.viewcontroller.main.IMainViewController; import javafx.scene.image.Image; @@ -76,7 +77,6 @@ public interface PlayPad { * * @return PadListener * - * @see 5.0.0 */ public List<PadListener> getPadListener(); @@ -106,4 +106,11 @@ public interface PlayPad { * Quelle des Plugin */ public void loadPlugin(URI uri); + + /** + * Gibt die globalen Einstellungen zurück. + * + * @return Global Settings + */ + public GlobalSettings getGlobalSettings(); } diff --git a/PlayWallCore/src/de/tobias/playpad/PlayPadPlugin.java b/PlayWallCore/src/de/tobias/playpad/PlayPadPlugin.java index ab386ef41209a5385e8bea4bab7b585c78811045..cdd076538f46abdcba1c2e01db8c252360a0723d 100644 --- a/PlayWallCore/src/de/tobias/playpad/PlayPadPlugin.java +++ b/PlayWallCore/src/de/tobias/playpad/PlayPadPlugin.java @@ -1,10 +1,14 @@ package de.tobias.playpad; +import de.tobias.playpad.project.Project; public final class PlayPadPlugin { private static PlayPad implementation; - + private static RegistryCollection registryCollection; + + private Project currentProject; + public static PlayPad getImplementation() { return implementation; } @@ -12,4 +16,21 @@ public final class PlayPadPlugin { protected static void setImplementation(PlayPad playPadMain) { implementation = playPadMain; } + + /** + * Gibt die Implementierung für die Registries + * + * @return Registry Collection Impl + */ + public static RegistryCollection getRegistryCollection() { + return registryCollection; + } + + protected static void setRegistryCollection(RegistryCollection registryCollection) { + PlayPadPlugin.registryCollection = registryCollection; + } + + public Project getCurrentproject() { + return currentProject; + } } diff --git a/PlayWallCore/src/de/tobias/playpad/RegistryCollection.java b/PlayWallCore/src/de/tobias/playpad/RegistryCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..c13e9df65df0fb3af5e87eb45c06d1a3b127ebbb --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/RegistryCollection.java @@ -0,0 +1,39 @@ +package de.tobias.playpad; + +import de.tobias.playpad.action.ActionConnect; +import de.tobias.playpad.action.mapper.MapperConnect; +import de.tobias.playpad.audio.AudioRegistry; +import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.pad.PadContentRegistry; +import de.tobias.playpad.pad.drag.PadDragMode; +import de.tobias.playpad.registry.DefaultRegistry; +import de.tobias.playpad.registry.Registry; +import de.tobias.playpad.tigger.TriggerItemConnect; +import de.tobias.playpad.view.main.MainLayoutConnect; + +/** + * Schnittstelle für die einzelen Registry. Hier sind alle Registries gesammelt, damit Komponenten registriert werden können. Die + * eigentliche Implementierung ist im Hauptprogramm. + * + * @author tobias + * + * @since 5.1.0 + */ +public interface RegistryCollection { + + public Registry<ActionConnect> getActions(); + + public AudioRegistry getAudioHandlers(); + + public Registry<PadDragMode> getDragModes(); + + public DefaultRegistry<DesignConnect> getDesigns(); + + public Registry<MapperConnect> getMappers(); + + public PadContentRegistry getPadContents(); + + public Registry<TriggerItemConnect> getTriggerItems(); + + public DefaultRegistry<MainLayoutConnect> getMainLayouts(); +} \ No newline at end of file diff --git a/PlayWallCore/src/de/tobias/playpad/Updatable.java b/PlayWallCore/src/de/tobias/playpad/Updatable.java new file mode 100644 index 0000000000000000000000000000000000000000..8d3b80e9f9bc64c26dd4b5d711ec78e30884304b --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/Updatable.java @@ -0,0 +1,74 @@ +package de.tobias.playpad; + +import java.net.URL; +import java.nio.file.Path; + +/** + * Diese Schnittstelle wird dafür verwendet, damit das Programm für Plugins nach Updates suchen kann und diese auch + * durchführen kann. + * + * @author tobias + * + * @since 5.0.0 + */ + +@Deprecated +public interface Updatable { + + /** + * Gibt die aktuelle Build Nummer zurück + * + * @return build number + */ + public int getCurrentBuild(); + + /** + * Gibt die altuelle Programmversion (lesbar) für den Nutzer zurück. + * + * @return version string + */ + public String getCurrentVersion(); + + /** + * Gibt die neue Buildnummer zurück. + * + * @return build number + */ + public int getNewBuild(); + + /** + * Gibt die neue Versionsnummer (lesbar) zurück. + * + * @return version string + */ + public String getNewVersion(); + + /** + * Lädt alle Informationen für Updates vom Server, sodass die Methoden bescheid wissen. + * + * @return <code>true</code> Erfolgreich. + */ + public boolean checkUpdate(); + + /** + * Gibt den Downloadlink für das Update zurück. + * + * @return server url + */ + public URL getDownloadPath(); + + /** + * Gibt den Lokalen Pfad zur Datei. + * + * @return local path + */ + public Path getLocalPath(); + + /** + * Gibt den Display Namen zurück. (lesbar) + * + * @return name + */ + public String name(); + +} diff --git a/PlayWallCore/src/de/tobias/playpad/action/Action.java b/PlayWallCore/src/de/tobias/playpad/action/Action.java index f142d444ac3b5b0486578fa0c0b406c8ef4dec12..6f7b10278df92f618eb7da1979c2dce02a33d5df 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/Action.java +++ b/PlayWallCore/src/de/tobias/playpad/action/Action.java @@ -13,12 +13,13 @@ import de.tobias.playpad.project.Project; import de.tobias.playpad.viewcontroller.main.IMainViewController; /** - * This class is the base of all program actions, that can be triggered by a mapper. This class handle all input form an mapper. + * Diese Klasse ist die Basis für alle Actions, die durch Mapper auftreten. Die Klasse verarbeitet dabei allen Input und führt die Listener + * aus. * * @author tobias * @version 5.0.0 * - * @see Mapper + * @see Mapper Mapper sind die Schnittstelle zur Hardware und bestandteil einer Action. */ public abstract class Action implements ActionDisplayable, Cloneable { @@ -30,7 +31,7 @@ public abstract class Action implements ActionDisplayable, Cloneable { * @param mapping * mapping */ - protected void setMapping(Mapping mapping) { + protected void setMappingRef(Mapping mapping) { this.mapping = mapping; } @@ -81,6 +82,9 @@ public abstract class Action implements ActionDisplayable, Cloneable { */ public abstract void initFeedback(Project project, IMainViewController controller); + /** + * Cleared das Feedback auf dem Mapper für diese Action. + */ public abstract void clearFeedback(); /** @@ -146,5 +150,12 @@ public abstract class Action implements ActionDisplayable, Cloneable { */ public abstract void save(Element root); + /** + * Dupliziert das Objekt. + * + * @return Cloned Object + * @throws CloneNotSupportedException + * Clone Fehlgeschlagen + */ public abstract Action cloneAction() throws CloneNotSupportedException; } diff --git a/PlayWallCore/src/de/tobias/playpad/action/ActionConnect.java b/PlayWallCore/src/de/tobias/playpad/action/ActionConnect.java index ae744a776ddb3c62c7f9055153867cdfca71fbbd..cdcdff5d913deee4384570704d04e683bb04429f 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/ActionConnect.java +++ b/PlayWallCore/src/de/tobias/playpad/action/ActionConnect.java @@ -5,15 +5,61 @@ import java.util.List; import de.tobias.playpad.settings.Profile; import javafx.scene.control.TreeItem; +/** + * Verwalter einer Action für die Instance und GUI. + * + * @author tobias + * + * @since 5.0.0 + * + * @see Action Implementierung der eigentlichen Action. + */ public abstract class ActionConnect { + /** + * Erstellt ein TreeItem für die Grupierung der Actions. + * + * @param actions + * Liste der alle Actionen dieses Types. + * @param mapping + * Mapping, indem die Actions sind. + * @return TreeItem + */ public abstract TreeItem<ActionDisplayable> getTreeViewForActions(List<Action> actions, Mapping mapping); + /** + * Initialisiert ein Mapping mit allen möglichen Action Varianten. Dies ist nötig, damit alle möglichen Actions in den Einstellungen + * aufgelistet werden können. + * + * @param mapping + * Mapping + * @param profile + * Profile für Einstellungen + * @param projectSettings + * Project Einstellungen + */ public abstract void initActionType(Mapping mapping, Profile profile); + /** + * Erstellt eine neue Instance der Aktion. + * + * @return Neue Instance. + */ public abstract Action newInstance(); + /** + * Gibt die Art der Action zurück. Gibt Auskunft über die Anordnung in den Einstellungen. + * + * @return Art der Aktion + * + * @see ActionType + */ public abstract ActionType geActionType(); + /** + * Gibt die ID der Action zurück. + * + * @return ID + */ public abstract String getType(); } diff --git a/PlayWallCore/src/de/tobias/playpad/action/ActionDisplayable.java b/PlayWallCore/src/de/tobias/playpad/action/ActionDisplayable.java index a96090537df984e9814f03ec78111013beae71f6..5c89514dd9d4c79007b656e10056245b1f1a1d45 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/ActionDisplayable.java +++ b/PlayWallCore/src/de/tobias/playpad/action/ActionDisplayable.java @@ -4,8 +4,26 @@ import de.tobias.playpad.Displayable; import de.tobias.playpad.viewcontroller.IMappingTabViewController; import de.tobias.utils.ui.ContentViewController; +/** + * Einn zusätzliches Interface für die Klasse {@link ActionConnect} oder {@link Action} mit der es möglich ist für ein ActionType oder eine + * Action Einstellungen anzuzeigen. + * + * @author tobias + * + * @since 5.0.0 + * + */ public interface ActionDisplayable extends Displayable { + /** + * Erlaubt es einen ViewController für diesen ActionType oder die Action zu schalten. + * + * @param mapping + * Aktuelles Mapping + * @param controller + * Aktueller ViewController für das Mapping + * @return ViewController für den ActionType + */ public default ContentViewController getActionSettingsViewController(Mapping mapping, IMappingTabViewController controller) { return null; } diff --git a/PlayWallCore/src/de/tobias/playpad/action/ActionRegistery.java b/PlayWallCore/src/de/tobias/playpad/action/ActionRegistery.java deleted file mode 100644 index 85a5a4350b65f5825d90601340ed997bcf5a9530..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/action/ActionRegistery.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.tobias.playpad.action; - -import java.util.HashMap; -import java.util.Set; - -public class ActionRegistery { - - private static HashMap<String, ActionConnect> actions; - - static { - actions = new HashMap<>(); - } - - public static void registerActionConnect(ActionConnect connect) { - actions.put(connect.getType(), connect); - } - - public static ActionConnect getActionConnect(String type) { - if (actions.containsKey(type)) { - return actions.get(type); - } else { - throw new IllegalArgumentException("Type of ActionConnect does not exists: " + type); - } - } - - public static Set<String> getTypes() { - return actions.keySet(); - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/action/ActionSerializer.java b/PlayWallCore/src/de/tobias/playpad/action/ActionSerializer.java index ca46cf05a6719eeaf52ac4800910b48596c31553..ff4c629b9b32b37ce6c1625db046ae5eed342927 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/ActionSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/action/ActionSerializer.java @@ -4,7 +4,10 @@ import java.util.List; import org.dom4j.Element; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.action.mapper.Mapper; +import de.tobias.playpad.action.mapper.MapperSerializer; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.xml.XMLDeserializer; import de.tobias.playpad.xml.XMLHandler; import de.tobias.playpad.xml.XMLSerializer; @@ -24,18 +27,24 @@ public class ActionSerializer implements XMLSerializer<Action>, XMLDeserializer< public Action loadElement(Element element) { String tpye = element.attributeValue(ACTION_TYPE); - Action action = ActionRegistery.getActionConnect(tpye).newInstance(); - action.load(element); + try { + Action action = PlayPadPlugin.getRegistryCollection().getActions().getComponent(tpye).newInstance(); + action.load(element); - boolean added = mapping.addActionIfNotContains(action); + boolean added = mapping.addActionIfNotContains(action); - if (added) { - XMLHandler<Mapper> handler = new XMLHandler<>(element); - List<Mapper> mappers = handler.loadElements(MAPPER, new MapperSerializer(action)); - mappers.forEach(action::addMapper); - } + if (added) { + XMLHandler<Mapper> handler = new XMLHandler<>(element); + List<Mapper> mappers = handler.loadElements(MAPPER, new MapperSerializer(action)); + mappers.forEach(action::addMapper); + } - return action; + return action; + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; } @Override diff --git a/PlayWallCore/src/de/tobias/playpad/action/ActionType.java b/PlayWallCore/src/de/tobias/playpad/action/ActionType.java index 21836940fd76aa70f06818d1b82f7df76ec5068d..4d562d989a06706773a044766db51e66e77f7027 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/ActionType.java +++ b/PlayWallCore/src/de/tobias/playpad/action/ActionType.java @@ -1,8 +1,21 @@ package de.tobias.playpad.action; +/** + * Art der Action. + * + * @author tobias + * + * @since 5.0.0 + */ public enum ActionType { + /** + * Steuerung einer Action, wie Kachel. + */ CONTROL, + /** + * Einstellungen ändern, wie Mute. + */ SETTINGS; } diff --git a/PlayWallCore/src/de/tobias/playpad/action/InputType.java b/PlayWallCore/src/de/tobias/playpad/action/InputType.java index 4b3eefd48bc4cd0d38f61b796cf4ea9dfd5b07b8..a59eb53980e204f0997dc4aa7314fec69187422f 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/InputType.java +++ b/PlayWallCore/src/de/tobias/playpad/action/InputType.java @@ -1,5 +1,12 @@ package de.tobias.playpad.action; +/** + * Optionne für die verschiedenen Input Möglichkeiten. + * + * @author tobias + * + * @since 5.0.0 + */ public enum InputType { /** diff --git a/PlayWallCore/src/de/tobias/playpad/action/MapperSerializer.java b/PlayWallCore/src/de/tobias/playpad/action/MapperSerializer.java deleted file mode 100644 index c9b60ef86ddb4c0bc8895726bda8a2da324a3fc8..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/action/MapperSerializer.java +++ /dev/null @@ -1,36 +0,0 @@ -package de.tobias.playpad.action; - -import org.dom4j.Element; - -import de.tobias.playpad.action.mapper.Mapper; -import de.tobias.playpad.action.mapper.MapperRegistry; -import de.tobias.playpad.xml.XMLDeserializer; -import de.tobias.playpad.xml.XMLSerializer; - -public class MapperSerializer implements XMLSerializer<Mapper>, XMLDeserializer<Mapper> { - - private static final String MAPPER_TYPE = "type"; - - private Action action; - - public MapperSerializer(Action action) { - this.action = action; - } - - @Override - public Mapper loadElement(Element element) { - String mapperType = element.attributeValue(MAPPER_TYPE); - - Mapper mapper = MapperRegistry.getMapperConnect(mapperType).createNewMapper(); - mapper.load(element, action); - return mapper; - } - - @Override - public void saveElement(Element newElement, Mapper data) { - newElement.addAttribute(MAPPER_TYPE, data.getType()); - data.save(newElement, action); - - } - -} diff --git a/PlayWallCore/src/de/tobias/playpad/action/Mapping.java b/PlayWallCore/src/de/tobias/playpad/action/Mapping.java index ccfe4072ff62b21e960c0358bf915f196cdfd884..434731682345ce9d284b5199e0a180e1f16e7385 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/Mapping.java +++ b/PlayWallCore/src/de/tobias/playpad/action/Mapping.java @@ -8,16 +8,18 @@ import java.util.UUID; import java.util.stream.Collectors; import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.action.feedback.ColorAdjuster; 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.action.mapper.MapperRegistry; import de.tobias.playpad.project.Project; +import de.tobias.playpad.registry.Registry; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.StringProperty; +// COMMENT Mapping public class Mapping implements Cloneable, ActionDisplayable { private String name; @@ -27,7 +29,6 @@ public class Mapping implements Cloneable, ActionDisplayable { public Mapping(boolean init, Profile profile) { mapping = new HashMap<>(); if (init) { - initActionType(profile); name = "Default"; uuid = UUID.randomUUID(); } @@ -89,7 +90,7 @@ public class Mapping implements Cloneable, ActionDisplayable { } } mapping.put(newAction, new ArrayList<>()); - newAction.setMapping(this); + newAction.setMappingRef(this); return true; } @@ -109,8 +110,9 @@ public class Mapping implements Cloneable, ActionDisplayable { } public void initActionType(Profile profile) { - for (String type : ActionRegistery.getTypes()) { - ActionRegistery.getActionConnect(type).initActionType(this, profile); + Registry<ActionConnect> actions = PlayPadPlugin.getRegistryCollection().getActions(); + for (ActionConnect component : actions.getComponents()) { + component.initActionType(this, profile); } } @@ -123,8 +125,8 @@ public class Mapping implements Cloneable, ActionDisplayable { } public void initFeedback() { - for (String mapperType : MapperRegistry.getTypes()) { - MapperConnect mapper = MapperRegistry.getMapperConnect(mapperType); + Registry<MapperConnect> registry = PlayPadPlugin.getRegistryCollection().getMappers(); + for (MapperConnect mapper : registry.getComponents()) { if (mapper instanceof MapperConnectFeedbackable) { ((MapperConnectFeedbackable) mapper).initFeedbackType(); } @@ -149,15 +151,20 @@ public class Mapping implements Cloneable, ActionDisplayable { } public void clearFeedback() { - for (String mapperType : MapperRegistry.getTypes()) { - MapperConnect mapper = MapperRegistry.getMapperConnect(mapperType); + Registry<MapperConnect> registry = PlayPadPlugin.getRegistryCollection().getMappers(); + for (MapperConnect mapper : registry.getComponents()) { if (mapper instanceof MapperConnectFeedbackable) { ((MapperConnectFeedbackable) mapper).clearFeedbackType(); } } + getActions().forEach(action -> action.clearFeedback()); } + public void adjustPadColorToMapper(Project project) { + ColorAdjuster.applyColorsToMappers(project); + } + @Override public Mapping clone() throws CloneNotSupportedException { Mapping clone = (Mapping) super.clone(); diff --git a/PlayWallCore/src/de/tobias/playpad/action/MappingList.java b/PlayWallCore/src/de/tobias/playpad/action/MappingList.java index 73b8805db3fd55ea103536049f84fb12557e6dbf..103a680c903e400930e37f9d7610e6e7b4c5eea6 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/MappingList.java +++ b/PlayWallCore/src/de/tobias/playpad/action/MappingList.java @@ -19,6 +19,7 @@ import org.dom4j.io.XMLWriter; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.xml.XMLHandler; +// COMMENT MappingList public class MappingList extends ArrayList<Mapping> { private static final long serialVersionUID = 1L; @@ -69,8 +70,8 @@ public class MappingList extends ArrayList<Mapping> { List<Mapping> loadMappings = handler.loadElements(MAPPING, new MappingSerializer(profile)); loadMappings.forEach(mapping -> { - mapping.initActionType(profile); // Update Actions, damit alle da sind und keine fehlt (falls eine - // gelöscht wurde auf der Datei) + mapping.initActionType(profile); // Update Actions, damit alle da sind und keine fehlt (falls eine gelöscht wurde + // auf der Datei) mapping.updateDisplayProperty(); mappings.add(mapping); }); @@ -95,9 +96,15 @@ public class MappingList extends ArrayList<Mapping> { Files.createDirectories(path.getParent()); Files.createFile(path); } - + XMLHandler<Mapping> handler = new XMLHandler<>(rootElement); handler.saveElements(MAPPING, this, new MappingSerializer()); + + if (Files.notExists(path)) { + Files.createDirectories(path.getParent()); + Files.createFile(path); + } + XMLHandler.save(path, document); } @@ -109,7 +116,7 @@ public class MappingList extends ArrayList<Mapping> { Element rootElement = document.getRootElement(); MappingSerializer mappingSerializer = new MappingSerializer(profile); - mapping = mappingSerializer.loadElement(rootElement); + mapping = mappingSerializer.loadElement(rootElement); mapping.setUuid(UUID.randomUUID()); return mapping; diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjustable.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjustable.java new file mode 100644 index 0000000000000000000000000000000000000000..01df8244bc74cce60d4a58507f1ba2f49bf119da --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjustable.java @@ -0,0 +1,11 @@ +package de.tobias.playpad.action.feedback; + +import de.tobias.playpad.pad.Pad; + +public interface ColorAdjustable { + + public boolean isAutoFeedbackColors(); + + public Pad getPad(); + +} diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java new file mode 100644 index 0000000000000000000000000000000000000000..8ca7614c0f368ead082b85c0be15a16c330e9379 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java @@ -0,0 +1,121 @@ +package de.tobias.playpad.action.feedback; + +import java.util.Set; + +import de.tobias.playpad.action.Action; +import de.tobias.playpad.action.mapper.Mapper; +import de.tobias.playpad.action.mapper.MapperFeedbackable; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.DesignColorAssociator; +import de.tobias.playpad.design.GlobalDesign; +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.settings.Profile; +import javafx.scene.paint.Color; +import javafx.scene.paint.Paint; + +/** + * Eine Klasse mit nützlichen Methoden um die Farben bei den Mappern anzupassen. + * + * @author tobias + * + * @since 5.1.0 + * + * @see ColorAdjustable Action muss dieses Interface dafür Implementieren, damit die Farbe Automatisch zum pad gemacht wird. + * @see ColorAssociator Mapper muss dieses Interface implemetieren, damit die entsprechenden Farbe gefunden werden kann + * + */ +public class ColorAdjuster { + + /** + * Übernimmt die Farben des Pads und den verknüpften Aktionen zu einem Pad auf die Mapper. + * + * @param project + * Aktuelles Projekt. + */ + public static void applyColorsToMappers(Project project) { + // Apply Layout to Mapper + Set<Action> actions = Profile.currentProfile().getMappings().getActiveMapping().getActions(); + for (Action action : actions) { + if (action instanceof ColorAdjustable) { + ColorAdjustable adjustable = (ColorAdjustable) action; + if (adjustable.isAutoFeedbackColors()) { + for (Mapper mapper : action.getMappers()) { + if (mapper instanceof MapperFeedbackable) { + mapColorForMapper(adjustable, mapper, project); + } + } + } + } + } + } + + // COMMENT ColorAdjuster + + private static void mapColorForMapper(ColorAdjustable cartAction, Mapper mapper, Project project) { + MapperFeedbackable feedbackable = (MapperFeedbackable) mapper; + if (feedbackable.supportFeedback() && mapper instanceof ColorAssociator) { + ColorAssociator colorAssociator = (ColorAssociator) mapper; + + Pad pad = cartAction.getPad(); + Color layoutStdColor = null; + Color layoutEvColor = null; + + if (pad.getPadSettings().isCustomLayout()) { + CartDesign layout = pad.getPadSettings().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(); + } + } + + if (layoutStdColor != null) { + DisplayableFeedbackColor associator = searchColor(colorAssociator, FeedbackMessage.STANDARD, layoutStdColor); + colorAssociator.setColor(FeedbackMessage.STANDARD, associator.mapperFeedbackValue()); + } + + if (layoutEvColor != null) { + DisplayableFeedbackColor associator = searchColor(colorAssociator, FeedbackMessage.EVENT, layoutEvColor); + colorAssociator.setColor(FeedbackMessage.EVENT, associator.mapperFeedbackValue()); + } + } + } + + protected static DisplayableFeedbackColor searchColor(ColorAssociator colorAssociator, FeedbackMessage message, Color color) { + DisplayableFeedbackColor minColor = colorAssociator.map(color); + if (minColor != null) { + return minColor; + } + double minVal = 1; + + for (DisplayableFeedbackColor feedbackColor : colorAssociator.getColors()) { + Paint paint = feedbackColor.getPaint(); + if (paint instanceof Color) { + Color c = (Color) paint; + double diff = Math.sqrt(Math.pow(c.getRed() - color.getRed(), 2) + Math.pow(c.getGreen() - color.getGreen(), 2) + + Math.pow(c.getBlue() - color.getBlue(), 2)); + if (minVal > diff) { + minVal = diff; + minColor = feedbackColor; + } + } + } + if (minColor != null && minVal < 0.35) { + return minColor; + } else if (message == FeedbackMessage.STANDARD) { + return colorAssociator.getDefaultStandardColor(); + } else if (message == FeedbackMessage.EVENT) { + return colorAssociator.getDefaultEventColor(); + } else { + return null; + } + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/DisplayableFeedbackColor.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/DisplayableFeedbackColor.java index bddd6f7278b1ba8f0a892910fa7c0b5938f2403e..034496deae66bc8587e4e151670b8c11cd0dc0ee 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/DisplayableFeedbackColor.java +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/DisplayableFeedbackColor.java @@ -4,6 +4,6 @@ import de.tobias.playpad.DisplayableColor; public interface DisplayableFeedbackColor extends DisplayableColor { - public int midiVelocity(); + public int mapperFeedbackValue(); } diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/Feedback.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/Feedback.java index e72c59d59907fae4882aa38e169855d2ef569e19..1ae1aadcc52e7bf29ceafe5769542ece50449a76 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/Feedback.java +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/Feedback.java @@ -2,16 +2,63 @@ package de.tobias.playpad.action.feedback; import org.dom4j.Element; +import de.tobias.playpad.action.mapper.Mapper; + +/** + * Das ist die Abstrakte Klasse für ein Feedback. Jedes Mapper Gerät kann eine eigene Klasse dafür entwickeln. Allerdings müssen gibt es ur + * eine beschränkte Anzahl an Typen von Feedbacks. + * + * @author tobias + * + * @since 5.0.0 + * + * @see FeedbackType Type des Feedbacks. Damit wird es im Mapper initalisiert. + * @see Mapper#initFeedback() Damit wird das Feedback initalisiert im Mapper. + */ public abstract class Feedback { + /** + * Gibt den Wert für das Gerät zurück, für eine bestimmte Aktion. + * + * @param message + * Art der Feedback Meldung + * @return Wert für den Mapper + */ public abstract int getValueForFeedbackMessage(FeedbackMessage message); + /** + * Setzt den Wert für eine Feedback Meldung. + * + * @param feedbackMessage + * Art der Feedback Meldung + * @param value + * Wert für den Mapper + */ public abstract void setFeedback(FeedbackMessage feedbackMessage, int value); - public abstract void load(Element root); + /** + * Lädt alle Informationen aus einem XML Objekt. + * + * @param feedbackObject + * XML Object. + */ + public abstract void load(Element feedbackObject); - public abstract void save(Element root); + /** + * Speichert die Informationen des Feedbacks in ein XML Objekt. + * + * @param feedbackObject + * Oberstes Objekt der XML Daten + */ + public abstract void save(Element feedbackObject); - public abstract Feedback cloneFeedback() throws CloneNotSupportedException ; + /** + * Dupliziert ein FeedbackObjeck. + * + * @return Duplikat. + * @throws CloneNotSupportedException + * Clone Fehlerhaft + */ + public abstract Feedback cloneFeedback() throws CloneNotSupportedException; } diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/FeedbackMessage.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/FeedbackMessage.java index 6b9ed3ce875153a719f9950b3a64f7f34e3d521e..564019e134cf796f76000fea17106bc843117460 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/FeedbackMessage.java +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/FeedbackMessage.java @@ -1,9 +1,30 @@ package de.tobias.playpad.action.feedback; +/** + * Arten von Feedback Meldungen. + * + * @author tobias + * + * @since 5.0.0 + * + * @see Feedback#getValueForFeedbackMessage(FeedbackMessage) + */ public enum FeedbackMessage { + /** + * Feedback Aus. + */ OFF, + /** + * Standart bei keiner Aktion. + */ STANDARD, + /** + * Besondere Aktion. + */ EVENT, + /** + * Wichtiger Hinweis auf dem Mapper. + */ WARNING; } diff --git a/PlayWallCore/src/de/tobias/playpad/action/mapper/Mapper.java b/PlayWallCore/src/de/tobias/playpad/action/mapper/Mapper.java index a64f8af9d6b822ba309a726271e562cabeba0267..2275187d26b014f77fbd61443be4e79b5dbc126b 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/mapper/Mapper.java +++ b/PlayWallCore/src/de/tobias/playpad/action/mapper/Mapper.java @@ -4,63 +4,93 @@ import org.dom4j.Element; import de.tobias.playpad.Displayable; import de.tobias.playpad.action.Action; -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.feedback.Feedback; import de.tobias.playpad.action.feedback.FeedbackType; -import javafx.scene.paint.Color; -import javafx.scene.paint.Paint; +/** + * Abstrakte Klasse für das Handling von Mappern. Die Aktionen und Handler werden von der Entsprechenden Aktion verwaltet, die dazu gehört. + * Jeder Mapper muss zu einer Aktion gehören. Zu jedem Mapper gehört auch ein Feedback. Dieses wird mittels Interfaces in der konktreten + * Implementation definiert. Diese abstrakte Klasse verwaltet allerdings nur den Type des Feedbacks. Die eigentloche Implementierung des + * Feedbacks ist Aufgabe des konkreten Mappers. + * + * @author tobias + * + * @since 5.0.0 + * + * @see Action Aktion, zu der ein Mapper gehört. + * @see Feedback Feedback für ein Mapper. + */ public abstract class Mapper implements Displayable, Cloneable { + /** + * Feedback für diesen Mapper. (Beispiel Feedback für eine Taste an einem MIDI Gerät. + */ protected FeedbackType feedbackType; + /** + * Setzt den FeedbackType des Mappers und initalisiert ihn. + * + * @param feedbackType + * neuer FeedbackType + * + * @see Mapper#initFeedback() wird automatisch aufgerufen. + * + */ + @Deprecated // Referenz auf Action, da Action den FeedbackType schon hat public void setFeedbackType(FeedbackType feedbackType) { this.feedbackType = feedbackType; initFeedback(); } + /** + * Gibt den FeedbackType für den entsprechenden Mapper zurück. + * + * @return FeedbackType für den Mapper. + */ + @Deprecated public FeedbackType getFeedbackType() { return feedbackType; } - public abstract String getType(); + /** + * Muss die entsprechende Implementierung des Feedbacks, sofern überhaupt benütigt initialisieren. Standart Implementierung ist leer, da + * optionale Methode. + */ + public void initFeedback() { + + } - protected abstract void initFeedback(); + /** + * ID des Mappers. + * + * @return IDs + */ + public abstract String getType(); + /** + * Deserialisierung der Daten + * + * @param element + * XML Element + * @param action + * Zugehörige Action + */ public abstract void load(Element element, Action action); - public abstract void save(Element element, Action action); + /** + * Speichert die Einstellungen eines Mappers. + * + * @param element + * Oberstes Objekt der XML Daten + */ + public abstract void save(Element element); + /** + * Dupliziert ein Mapper Objekt. + * + * @return Duplikat. + * @throws CloneNotSupportedException Clone Fehlgeschlagen + */ public abstract Mapper cloneMapper() throws CloneNotSupportedException; - public static DisplayableFeedbackColor searchColor(ColorAssociator colorAssociator, FeedbackMessage message, Color color) { - DisplayableFeedbackColor minColor = colorAssociator.map(color); - if (minColor != null) { - return minColor; - } - double minVal = 1; - - for (DisplayableFeedbackColor feedbackColor : colorAssociator.getColors()) { - Paint paint = feedbackColor.getPaint(); - if (paint instanceof Color) { - Color c = (Color) paint; - double diff = Math.sqrt(Math.pow(c.getRed() - color.getRed(), 2) + Math.pow(c.getGreen() - color.getGreen(), 2) - + Math.pow(c.getBlue() - color.getBlue(), 2)); - if (minVal > diff) { - minVal = diff; - minColor = feedbackColor; - } - } - } - if (minColor != null && minVal < 0.35) { - return minColor; - } else if (message == FeedbackMessage.STANDARD) { - return colorAssociator.getDefaultStandardColor(); - } else if (message == FeedbackMessage.EVENT) { - return colorAssociator.getDefaultEventColor(); - } else { - return null; - } - } } diff --git a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperRegistry.java b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperRegistry.java index 573c2055b2982f75e637ce3aa1963329dc5d490a..ea795f46ebab8df397805d40be37c6a54a737ca2 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperRegistry.java +++ b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperRegistry.java @@ -1,34 +1,11 @@ package de.tobias.playpad.action.mapper; -import java.util.HashMap; -import java.util.Set; - import de.tobias.playpad.viewcontroller.IMapperOverviewViewController; +@Deprecated public class MapperRegistry { - private static HashMap<String, MapperConnect> mappers; - - static { - mappers = new HashMap<>(); - } - - public static void registerMapperConnect(MapperConnect connect) { - mappers.put(connect.getType(), connect); - } - - public static MapperConnect getMapperConnect(String type) { - if (mappers.containsKey(type)) { - return mappers.get(type); - } else { - throw new IllegalArgumentException("Tpye of MapperConnect does not exists: " + type); - } - } - - public static Set<String> getTypes() { - return mappers.keySet(); - } - + // TODO New Implementation private static IMapperOverviewViewController controllerInstance; public static void setOverviewViewController(IMapperOverviewViewController controller) { diff --git a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperSerializer.java b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..604f33b3ddc14c39556638c315fc02d8d51d9cff --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperSerializer.java @@ -0,0 +1,52 @@ +package de.tobias.playpad.action.mapper; + +import org.dom4j.Element; + +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.action.Action; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.xml.XMLDeserializer; +import de.tobias.playpad.xml.XMLSerializer; + +/** + * Laden und Speichern von Mappern (Array von Mappern) + * + * @author tobias + * + * @since 5.0.1 + */ +public class MapperSerializer implements XMLSerializer<Mapper>, XMLDeserializer<Mapper> { + + private static final String MAPPER_TYPE = "type"; + + private Action action; + + public MapperSerializer(Action action) { + this.action = action; + } + + @Override + public Mapper loadElement(Element element) { + String mapperType = element.attributeValue(MAPPER_TYPE); + + try { + MapperConnect component = PlayPadPlugin.getRegistryCollection().getMappers().getComponent(mapperType); + + Mapper mapper = component.createNewMapper(); + mapper.load(element, action); + return mapper; + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + @Override + public void saveElement(Element newElement, Mapper data) { + newElement.addAttribute(MAPPER_TYPE, data.getType()); + data.save(newElement); + + } + +} diff --git a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperViewController.java b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperViewController.java index 0725142845fadb9fead0d3f5ff819aef15c6a36c..d4592c558d7a11a716a53ef8bcb7c9b838eb22cc 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperViewController.java @@ -4,6 +4,14 @@ import java.util.ResourceBundle; import de.tobias.utils.ui.ContentViewController; +/** + * Übersicht über die Mapper zu einer Action.s + * + * @author tobias + * + * @since 5.0.0 + * + */ public abstract class MapperViewController extends ContentViewController { public MapperViewController(String name, String path, ResourceBundle localization) { @@ -16,5 +24,10 @@ public abstract class MapperViewController extends ContentViewController { public abstract Mapper getMapper(); - public abstract void showInputMapperUI(); + /** + * Zeigt einen Dialog für die Eingabe des Mappers. + * + * @return <code>true</code> Erfolgreiche Einageb, <code>false</code> Abbruch oder Fehler. + */ + public abstract boolean showInputMapperUI(); } diff --git a/PlayWallCore/src/de/tobias/playpad/action/mididevice/Device.java b/PlayWallCore/src/de/tobias/playpad/action/mididevice/Device.java index 031fb34af63394bb8ecd75c54952e7a52171812f..e8d46339804f3024b3d0726fa1e8e2981e17f522 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/mididevice/Device.java +++ b/PlayWallCore/src/de/tobias/playpad/action/mididevice/Device.java @@ -17,7 +17,8 @@ import de.tobias.playpad.midi.device.DeviceRegistry; * Erstellen automatisch auf Implementierung. Mögliche Interfaces: DeviceColorAssociatorConnector * * @author tobias - * + * + * @since 5.0.0 */ public abstract class Device extends EventDispatcher implements Listener { diff --git a/PlayWallCore/src/de/tobias/playpad/audio/AudioHandler.java b/PlayWallCore/src/de/tobias/playpad/audio/AudioHandler.java index adf948d31e2541f227622c6d79a1919cc7e5f261..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; } @@ -39,6 +38,7 @@ public abstract class AudioHandler { public abstract boolean isMediaLoaded(); + // TODO Auch einzelne Dateien laden public abstract void loadMedia(Path[] paths); public abstract void unloadMedia(); 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 1915994cbf6a43de36050641abb7bb575e8e55d3..bb44d27af8784edf2e56d18dc88e87265644501b 100644 --- a/PlayWallCore/src/de/tobias/playpad/audio/AudioRegistry.java +++ b/PlayWallCore/src/de/tobias/playpad/audio/AudioRegistry.java @@ -1,36 +1,20 @@ package de.tobias.playpad.audio; -import java.util.HashMap; - +import de.tobias.playpad.registry.DefaultComponentRegistry; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; -public class AudioRegistry { - - private static String defaultAudioInterface; - private static HashMap<String, AudioHandlerConnect> audioSystems = new HashMap<>(); - - public static void register(AudioHandlerConnect type, String name) { - audioSystems.put(name, type); - } +public class AudioRegistry extends DefaultComponentRegistry<AudioHandlerConnect> { - public static HashMap<String, AudioHandlerConnect> getAudioSystems() { - return audioSystems; + public AudioRegistry() { + super("Audio Handler"); } - public static AudioHandlerConnect geAudioType() { - String impl = Profile.currentProfile().getProfileSettings().getAudioClass(); - if (audioSystems.containsKey(impl)) { - return audioSystems.get(impl); - } else { - return audioSystems.get(defaultAudioInterface); + public AudioHandlerConnect getCurrentAudioHandler() { + try { + return getComponent(Profile.currentProfile().getProfileSettings().getAudioClass()); + } catch (NoSuchComponentException e) { + return getDefault(); } } - - public static String getDefaultAudioInterface() { - return defaultAudioInterface; - } - - public static void setDefaultAudioInterface(String defaultAudioInterface) { - AudioRegistry.defaultAudioInterface = defaultAudioInterface; - } } diff --git a/PlayWallCore/src/de/tobias/playpad/layout/CartLayout.java b/PlayWallCore/src/de/tobias/playpad/design/CartDesign.java similarity index 65% rename from PlayWallCore/src/de/tobias/playpad/layout/CartLayout.java rename to PlayWallCore/src/de/tobias/playpad/design/CartDesign.java index 9f9fabc5ddee03ced42dca9441a1e62c451fd8f9..12d6f3a81c062d1bfc85fa226e8800cd59306396 100644 --- a/PlayWallCore/src/de/tobias/playpad/layout/CartLayout.java +++ b/PlayWallCore/src/de/tobias/playpad/design/CartDesign.java @@ -1,11 +1,11 @@ -package de.tobias.playpad.layout; +package de.tobias.playpad.design; import org.dom4j.Element; -import de.tobias.playpad.pad.view.IPadViewController; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Warning; -public interface CartLayout { +public interface CartDesign { public String convertToCss(String classSufix, boolean fullCss); @@ -19,17 +19,14 @@ public interface CartLayout { */ public void save(Element rootElement); - /** + /* * Wird in einem neuen Thread aufgerufen - * - * @param controller - * @param warning */ - public abstract void handleWarning(IPadViewController controller, Warning warning, GlobalLayout animate); + public abstract void handleWarning(IPadViewController controller, Warning warning, GlobalDesign animate); public default void stopWarning(IPadViewController controller) {} public void reset(); - public void copyGlobalLayout(GlobalLayout globalLayout); + public void copyGlobalLayout(GlobalDesign globalLayout); } diff --git a/PlayWallCore/src/de/tobias/playpad/layout/Layout.java b/PlayWallCore/src/de/tobias/playpad/design/Design.java similarity index 90% rename from PlayWallCore/src/de/tobias/playpad/layout/Layout.java rename to PlayWallCore/src/de/tobias/playpad/design/Design.java index 9000f4f1b53d92e3e769084cf439d763a0ea97b2..25c6f540837b40c08edcc2f1fc3e543f62438dce 100644 --- a/PlayWallCore/src/de/tobias/playpad/layout/Layout.java +++ b/PlayWallCore/src/de/tobias/playpad/design/Design.java @@ -1,6 +1,6 @@ -package de.tobias.playpad.layout; +package de.tobias.playpad.design; -public abstract class Layout { +public abstract class Design { protected void startStyleClass(StringBuilder builder, String name) { builder.append("." + name + " {\n"); diff --git a/PlayWallCore/src/de/tobias/playpad/layout/LayoutColorAssociator.java b/PlayWallCore/src/de/tobias/playpad/design/DesignColorAssociator.java similarity index 62% rename from PlayWallCore/src/de/tobias/playpad/layout/LayoutColorAssociator.java rename to PlayWallCore/src/de/tobias/playpad/design/DesignColorAssociator.java index a86f590c869cbeeb0a0282b15f83245edd88ffa4..1fc348f64781d214661cfb62e72cef4f61563dec 100644 --- a/PlayWallCore/src/de/tobias/playpad/layout/LayoutColorAssociator.java +++ b/PlayWallCore/src/de/tobias/playpad/design/DesignColorAssociator.java @@ -1,8 +1,8 @@ -package de.tobias.playpad.layout; +package de.tobias.playpad.design; import javafx.scene.paint.Color; -public interface LayoutColorAssociator { +public interface DesignColorAssociator { public Color getAssociatedStandardColor(); diff --git a/PlayWallCore/src/de/tobias/playpad/design/DesignConnect.java b/PlayWallCore/src/de/tobias/playpad/design/DesignConnect.java new file mode 100644 index 0000000000000000000000000000000000000000..c38d3368ade34b03bfccde7babae7bffedff31c8 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/design/DesignConnect.java @@ -0,0 +1,18 @@ +package de.tobias.playpad.design; + +import de.tobias.playpad.Displayable; +import de.tobias.playpad.viewcontroller.CartDesignViewController; +import de.tobias.playpad.viewcontroller.GlobalDesignViewController; + +public abstract class DesignConnect implements Displayable { + + public abstract String getType(); + + public abstract CartDesign newCartDesign(); + + public abstract GlobalDesign newGlobalDesign(); + + public abstract CartDesignViewController getCartDesignViewController(CartDesign cartLayout); + + public abstract GlobalDesignViewController getGlobalDesignViewController(GlobalDesign globalLayout); +} diff --git a/PlayWallCore/src/de/tobias/playpad/layout/FadeableColor.java b/PlayWallCore/src/de/tobias/playpad/design/FadeableColor.java similarity index 98% rename from PlayWallCore/src/de/tobias/playpad/layout/FadeableColor.java rename to PlayWallCore/src/de/tobias/playpad/design/FadeableColor.java index 2debe19d6e2a789b06a343c225e109b9ef004476..5dcafef9182693e04b01d769757a637b0dea3e49 100644 --- a/PlayWallCore/src/de/tobias/playpad/layout/FadeableColor.java +++ b/PlayWallCore/src/de/tobias/playpad/design/FadeableColor.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.layout; +package de.tobias.playpad.design; import java.util.ArrayList; import java.util.List; diff --git a/PlayWallCore/src/de/tobias/playpad/layout/GlobalLayout.java b/PlayWallCore/src/de/tobias/playpad/design/GlobalDesign.java similarity index 71% rename from PlayWallCore/src/de/tobias/playpad/layout/GlobalLayout.java rename to PlayWallCore/src/de/tobias/playpad/design/GlobalDesign.java index e7b95f72544c09c02a9168923ffc74bdacdffb0a..de0fe92c4eed206e06e9191ff8feb511f58a134e 100644 --- a/PlayWallCore/src/de/tobias/playpad/layout/GlobalLayout.java +++ b/PlayWallCore/src/de/tobias/playpad/design/GlobalDesign.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.layout; +package de.tobias.playpad.design; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -14,13 +14,16 @@ import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; -import de.tobias.playpad.pad.view.IPadViewController; +import de.tobias.playpad.PlayPadPlugin; +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; import de.tobias.playpad.settings.Warning; import de.tobias.playpad.viewcontroller.main.IMainViewController; import javafx.stage.Stage; -public interface GlobalLayout { +public interface GlobalDesign { public void applyCss(Stage stage); @@ -44,11 +47,8 @@ public interface GlobalLayout { public double getPadHeight(); - /** + /* * Wird in einem neuen Thread aufgerufen - * - * @param controller - * @param warning */ public void handleWarning(IPadViewController controller, Warning warning); @@ -57,14 +57,14 @@ public interface GlobalLayout { public void reset(); // Utils - public static void saveGlobal(HashMap<String, GlobalLayout> layouts, Path path) throws UnsupportedEncodingException, IOException { + public static void saveGlobal(HashMap<String, GlobalDesign> layouts, Path path) throws UnsupportedEncodingException, IOException { Document document = DocumentHelper.createDocument(); Element rootElement = document.addElement("Layouts"); for (String key : layouts.keySet()) { Element layoutElement = rootElement.addElement("Layout"); layoutElement.addAttribute("type", key); - GlobalLayout layout = layouts.get(key); + GlobalDesign layout = layouts.get(key); layout.save(layoutElement); } @@ -73,20 +73,28 @@ public interface GlobalLayout { writer.close(); } - public static HashMap<String, GlobalLayout> loadGlobalLayout(Path path) throws DocumentException, IOException { - HashMap<String, GlobalLayout> layouts = new HashMap<>(); + public static HashMap<String, GlobalDesign> loadGlobalLayout(Path path) throws DocumentException, IOException { + HashMap<String, GlobalDesign> layouts = new HashMap<>(); if (Files.exists(path)) { SAXReader reader = new SAXReader(); Document document = reader.read(Files.newInputStream(path)); Element root = document.getRootElement(); + DefaultRegistry<DesignConnect> layouts2 = PlayPadPlugin.getRegistryCollection().getDesigns(); + for (Object layoutObj : root.elements("Layout")) { Element layoutElement = (Element) layoutObj; String type = layoutElement.attributeValue("type"); - GlobalLayout layout = LayoutRegistry.getLayout(type).newGlobalLayout(); - layout.load(layoutElement); - layouts.put(type, layout); + + try { + GlobalDesign layout = layouts2.getComponent(type).newGlobalDesign(); + layout.load(layoutElement); + layouts.put(type, layout); + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } diff --git a/PlayWallCore/src/de/tobias/playpad/layout/LayoutConnect.java b/PlayWallCore/src/de/tobias/playpad/layout/LayoutConnect.java deleted file mode 100644 index cce24c37d7aff5a305591c2f9353d27ab9b6c74d..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/layout/LayoutConnect.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.tobias.playpad.layout; - -import de.tobias.playpad.Displayable; -import de.tobias.playpad.viewcontroller.CartLayoutViewController; -import de.tobias.playpad.viewcontroller.GlobalLayoutViewController; - -public abstract class LayoutConnect implements Displayable { - - public abstract String getType(); - - public abstract CartLayout newCartLayout(); - - public abstract GlobalLayout newGlobalLayout(); - - public abstract CartLayoutViewController getCartLayoutViewController(CartLayout cartLayout); - - public abstract GlobalLayoutViewController getGlobalLayoutViewController(GlobalLayout globalLayout); -} diff --git a/PlayWallCore/src/de/tobias/playpad/layout/LayoutRegistry.java b/PlayWallCore/src/de/tobias/playpad/layout/LayoutRegistry.java deleted file mode 100644 index 33d8d7b792281eb77e936c5163257258293120b7..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/layout/LayoutRegistry.java +++ /dev/null @@ -1,39 +0,0 @@ -package de.tobias.playpad.layout; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Set; - -public class LayoutRegistry { - - static { - layouts = new HashMap<>(); - } - - private static String defaultLayout; - private static HashMap<String, LayoutConnect> layouts; - - public static void registerLayout(LayoutConnect layoutConnect) { - layouts.put(layoutConnect.getType(), layoutConnect); - } - - public static Set<String> getTypes() { - return layouts.keySet(); - } - - public static LayoutConnect getLayout(String type) { - return layouts.get(type); - } - - public static Collection<LayoutConnect> getValues() { - return layouts.values(); - } - - public static String getDefaultLayout() { - return defaultLayout; - } - - public static void setDefaultLayout(String defaultLayout) { - LayoutRegistry.defaultLayout = defaultLayout; - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/Pad.java b/PlayWallCore/src/de/tobias/playpad/pad/Pad.java index ae4adf2d2df16e8188455b46ec81dc8f01df1aa1..33993d3376e81ec3c9febde2ab568e1732b7496f 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/Pad.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/Pad.java @@ -1,29 +1,19 @@ package de.tobias.playpad.pad; import java.nio.file.Path; -import java.util.HashMap; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.LayoutRegistry; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.pad.conntent.Pauseable; -import de.tobias.playpad.pad.triggerlistener.PadTriggerContentListener; -import de.tobias.playpad.pad.triggerlistener.PadTriggerDurationListener; -import de.tobias.playpad.pad.triggerlistener.PadTriggerStatusListener; -import de.tobias.playpad.pad.view.IPadViewController; +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.IPadViewController; import de.tobias.playpad.project.Project; -import de.tobias.playpad.settings.Fade; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.Warning; -import de.tobias.playpad.tigger.Trigger; -import de.tobias.playpad.tigger.TriggerPoint; -import javafx.beans.binding.BooleanBinding; -import javafx.beans.property.BooleanProperty; +import de.tobias.playpad.registry.NoSuchComponentException; import javafx.beans.property.DoubleProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.ReadOnlyIntegerProperty; -import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleObjectProperty; @@ -32,26 +22,16 @@ import javafx.beans.property.StringProperty; public class Pad { + // Verwaltung private IntegerProperty indexProperty = new SimpleIntegerProperty(); private StringProperty nameProperty = new SimpleStringProperty(); private ObjectProperty<PadStatus> statusProperty = new SimpleObjectProperty<>(PadStatus.EMPTY); + // Content private ObjectProperty<PadContent> contentProperty = new SimpleObjectProperty<>(); // Settings - private DoubleProperty volumeProperty = new SimpleDoubleProperty(1.0); - private BooleanProperty loopProperty = new SimpleBooleanProperty(false); - private ObjectProperty<TimeMode> timeModeProperty = new SimpleObjectProperty<>(); - private ObjectProperty<Fade> fadeProperty = new SimpleObjectProperty<>(); - private ObjectProperty<Warning> warningProperty = new SimpleObjectProperty<>(); - - private BooleanProperty customLayoutProperty = new SimpleBooleanProperty(false); - private HashMap<String, CartLayout> layouts = new HashMap<>(); - - private HashMap<String, Object> customSettings = new HashMap<>(); - - // Trigger - private HashMap<TriggerPoint, Trigger> triggers = new HashMap<>(); + private PadSettings padSettings; // Custom Volume private transient DoubleProperty customVolumeProperty = new SimpleDoubleProperty(1.0); @@ -72,6 +52,7 @@ public class Pad { public Pad(Project project) { this.project = project; + padSettings = new PadSettings(); initPadListener(); // Update Trigger ist nicht notwendig, da es in load(Element) ausgerufen wird @@ -79,11 +60,13 @@ public class Pad { public Pad(Project project, int index) { this.project = project; + padSettings = new PadSettings(); + setIndex(index); setStatus(PadStatus.EMPTY); initPadListener(); - updateTrigger(); + padSettings.updateTrigger(); } public Pad(Project project, int index, String name, PadContent content) { @@ -103,6 +86,7 @@ public class Pad { // Das ist für die Position Listener notwendig, wenn sich der Content ändert padTriggerContentListener = new PadTriggerContentListener(this); + contentProperty.addListener(padTriggerContentListener); padTriggerContentListener.changed(contentProperty, null, getContent()); } @@ -154,6 +138,7 @@ public class Pad { if (status == PadStatus.STOP && getStatus() == PadStatus.READY) { return; } + this.statusProperty.set(status); } @@ -178,12 +163,8 @@ public class Pad { return contentProperty; } - public double getVolume() { - return volumeProperty.get(); - } - - public void setVolume(double volume) { - volumeProperty.set(volume); + public PadSettings getPadSettings() { + return padSettings; } public void setMasterVolume(double volume) { @@ -192,129 +173,6 @@ public class Pad { } } - public DoubleProperty volumeProperty() { - return volumeProperty; - } - - public boolean isLoop() { - return loopProperty.get(); - } - - public void setLoop(boolean loop) { - this.loopProperty.set(loop); - } - - public BooleanProperty loopProperty() { - return loopProperty; - } - - public boolean isCustomTimeMode() { - return timeModeProperty.isNotNull().get(); - } - - public BooleanBinding customTimeModeProperty() { - return timeModeProperty.isNotNull(); - } - - public TimeMode getTimeMode() { - if (timeModeProperty.isNull().get()) { - if (Profile.currentProfile() != null) { - return Profile.currentProfile().getProfileSettings().getPlayerTimeDisplayMode(); - } - } - return timeModeProperty.get(); - } - - public void setTimeMode(TimeMode timeMode) { - this.timeModeProperty.set(timeMode); - } - - public ObjectProperty<TimeMode> timeModeProperty() { - return timeModeProperty; - } - - public boolean isCustomFade() { - return fadeProperty.isNotNull().get(); - } - - public BooleanBinding customFadeProperty() { - return fadeProperty.isNotNull(); - } - - /** - * Returns either the fade settings of this pad or the global settings - * - * @return - */ - public Fade getFade() { - if (fadeProperty.isNull().get()) { - if (Profile.currentProfile() != null) { - return Profile.currentProfile().getProfileSettings().getFade(); - } - } - return fadeProperty.get(); - } - - public void setFade(Fade fade) { - this.fadeProperty.set(fade); - } - - public ObjectProperty<Fade> fadeProperty() { - return fadeProperty; - } - - public boolean isCustomWarning() { - return warningProperty.isNotNull().get(); - } - - public BooleanBinding customWarningProperty() { - return warningProperty.isNotNull(); - } - - public Warning getWarning() { - if (warningProperty.isNull().get()) { - if (Profile.currentProfile() != null) { - return Profile.currentProfile().getProfileSettings().getWarningFeedback(); - } - } - return warningProperty.get(); - } - - public void setWarning(Warning warning) { - this.warningProperty.set(warning); - } - - public ObjectProperty<Warning> warningProperty() { - return warningProperty; - } - - public boolean isCustomLayout() { - return customLayoutProperty.get(); - } - - public void setCustomLayout(boolean customLayout) { - this.customLayoutProperty.set(customLayout); - } - - public BooleanProperty customLayoutProperty() { - return customLayoutProperty; - } - - public CartLayout getLayout() { - return getLayout(Profile.currentProfile().getProfileSettings().getLayoutType()); - } - - public CartLayout getLayout(String type) { - if (!layouts.containsKey(type)) { - layouts.put(type, LayoutRegistry.getLayout(type).newCartLayout()); - } - return layouts.get(type); - } - - public void setLayout(CartLayout layout, String type) { - this.layouts.put(type, layout); - } - public boolean isEof() { return eof; } @@ -323,20 +181,8 @@ public class Pad { this.eof = eof; } - public HashMap<String, Object> getCustomSettings() { - return customSettings; - } - - public HashMap<TriggerPoint, Trigger> getTriggers() { - return triggers; - } - - public Trigger getTrigger(TriggerPoint point) { - return triggers.get(point); - } - // Helper Methodes - public void loadContent() { + public void loadContent() throws NoSuchComponentException { if (contentProperty.get() != null) contentProperty.get().loadMedia(); } @@ -369,23 +215,6 @@ public class Pad { this.ignoreTrigger = ignoreTrigger; } - void updateTrigger() { - for (TriggerPoint point : TriggerPoint.values()) { - if (!triggers.containsKey(point)) { - Trigger trigger = new Trigger(point); - triggers.put(point, trigger); - } - } - } - - public boolean hasTriggerItems() { - for (Trigger trigger : triggers.values()) { - if (!trigger.getItems().isEmpty()) - return true; - } - return false; - } - public Project getProject() { return project; } @@ -435,8 +264,4 @@ public class Pad { public DoubleProperty customVolumeProperty() { return customVolumeProperty; } - - HashMap<String, CartLayout> getLayouts() { - return layouts; - } } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadContentRegistry.java b/PlayWallCore/src/de/tobias/playpad/pad/PadContentRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..522a30692b022e4586e91bacfac5b01556fcd980 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadContentRegistry.java @@ -0,0 +1,43 @@ +package de.tobias.playpad.pad; + +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import de.tobias.playpad.pad.conntent.PadContentConnect; +import de.tobias.playpad.registry.ComponentRegistry; +import de.tobias.playpad.registry.NoSuchComponentException; + +public class PadContentRegistry extends ComponentRegistry<PadContentConnect> { + + public PadContentRegistry(String name) { + super(name); + } + + public Set<PadContentConnect> getPadContentConnectsForFile(Path path) throws NoSuchComponentException { + Set<PadContentConnect> connects = new HashSet<>(); + for (String type : getTypes()) { + PadContentConnect connect = getComponent(type); + for (String extension : connect.getSupportedTypes()) { + if (path.getFileName().toString().toLowerCase().matches("." + extension)) { + connects.add(connect); + } + } + } + return connects; + } + + public String[] getSupportedFileTypes() throws NoSuchComponentException { + List<String> extensions = new ArrayList<>(); + for (String type : getTypes()) { + PadContentConnect connect = getComponent(type); + String[] fileExtensions = connect.getSupportedTypes(); + Collections.addAll(extensions, fileExtensions); + } + return extensions.toArray(new String[extensions.size()]); + } + +} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadException.java b/PlayWallCore/src/de/tobias/playpad/pad/PadException.java index 9f236beb67b3811478c922078f59cb8a207da519..c0185d7f711412253689e4be8dde241fdae4a852 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadException.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadException.java @@ -6,7 +6,7 @@ import java.nio.file.Path; import javax.sound.sampled.UnsupportedAudioFileException; -import de.tobias.playpad.pad.conntent.UnkownPadContentException; +import de.tobias.playpad.registry.NoSuchComponentException; import javafx.scene.media.MediaException; import javazoom.jl.decoder.JavaLayerException; @@ -41,7 +41,7 @@ public class PadException extends Exception { type = PadExceptionType.CONVERT_NOT_SUPPORTED; } else if (ex instanceof IOException) { type = PadExceptionType.UNKOWN; - } else if (ex instanceof UnkownPadContentException) { + } else if (ex instanceof NoSuchComponentException) { type = PadExceptionType.UNKOWN_CONTENT_TYPE; } else if (ex instanceof Exception) { type = PadExceptionType.UNKOWN; diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java index 298456087dcecb18d89aa53c655a4472979a247d..ac129cacd5405fc967e5a1d2914473ff53229ccc 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java @@ -2,12 +2,15 @@ package de.tobias.playpad.pad; import org.dom4j.Element; -import de.tobias.playpad.layout.CartLayout; -import de.tobias.playpad.layout.LayoutRegistry; +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.DesignConnect; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.pad.conntent.PadContentRegistry; -import de.tobias.playpad.pad.conntent.UnkownPadContentException; +import de.tobias.playpad.pad.conntent.PadContentConnect; import de.tobias.playpad.project.Project; +import de.tobias.playpad.registry.DefaultRegistry; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.registry.Registry; import de.tobias.playpad.settings.Fade; import de.tobias.playpad.settings.Warning; import de.tobias.playpad.tigger.Trigger; @@ -62,32 +65,41 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { // Settings Element settingsElement = element.element(SETTINGS_ELEMENT); + PadSettings padSettings = pad.getPadSettings(); + if (settingsElement.element(VOLUME_ELEMENT) != null) - pad.setVolume(Double.valueOf(settingsElement.element(VOLUME_ELEMENT).getStringValue())); + padSettings.setVolume(Double.valueOf(settingsElement.element(VOLUME_ELEMENT).getStringValue())); if (settingsElement.element(LOOP_ELEMENT) != null) - pad.setLoop(Boolean.valueOf(settingsElement.element(LOOP_ELEMENT).getStringValue())); + padSettings.setLoop(Boolean.valueOf(settingsElement.element(LOOP_ELEMENT).getStringValue())); if (settingsElement.element(TIMEMODE_ELEMENT) != null) - pad.setTimeMode(TimeMode.valueOf(settingsElement.element(TIMEMODE_ELEMENT).getStringValue())); + padSettings.setTimeMode(TimeMode.valueOf(settingsElement.element(TIMEMODE_ELEMENT).getStringValue())); if (settingsElement.element(FADE_ELEMENT) != null) - pad.setFade(Fade.load(settingsElement.element(FADE_ELEMENT))); + padSettings.setFade(Fade.load(settingsElement.element(FADE_ELEMENT))); if (settingsElement.element(WARNING_ELEMENT) != null) - pad.setWarning(Warning.load(settingsElement.element(WARNING_ELEMENT))); + padSettings.setWarning(Warning.load(settingsElement.element(WARNING_ELEMENT))); // Laoyut Element layoutsElement = settingsElement.element(LAYOUTS_ELEMENT); if (layoutsElement != null) { if (layoutsElement.attributeValue(LAYOUT_ACTIVE_ATTR) != null) { - pad.setCustomLayout(Boolean.valueOf(layoutsElement.attributeValue(LAYOUT_ACTIVE_ATTR))); + padSettings.setCustomLayout(Boolean.valueOf(layoutsElement.attributeValue(LAYOUT_ACTIVE_ATTR))); } for (Object layoutObj : layoutsElement.elements(LAYOUT_ELEMENT)) { if (layoutObj instanceof Element) { Element layoutElement = (Element) layoutObj; String type = layoutElement.attributeValue(LAYOUT_TYPE_ATTR); - CartLayout layout = LayoutRegistry.getLayout(type).newCartLayout(); - layout.load(layoutElement); - pad.setLayout(layout, type); + try { + DefaultRegistry<DesignConnect> layouts = PlayPadPlugin.getRegistryCollection().getDesigns(); + CartDesign layout = layouts.getComponent(type).newCartDesign(); + layout.load(layoutElement); + + padSettings.setLayout(layout, type); + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } } } @@ -99,7 +111,7 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { Element item = (Element) object; String key = item.attributeValue(CUSTOM_SETTINGS_TYPE_ATTR); Object data = UserDefaults.loadElement(item); - pad.getCustomSettings().put(key, data); + padSettings.getCustomSettings().put(key, data); } } } @@ -112,21 +124,24 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { Element triggerElement = (Element) triggerObj; Trigger trigger = new Trigger(); trigger.load(triggerElement); - pad.getTriggers().put(trigger.getTriggerPoint(), trigger); + padSettings.getTriggers().put(trigger.getTriggerPoint(), trigger); } } } - pad.updateTrigger(); // Damit alle Points da sind + padSettings.updateTrigger(); // Damit alle Points da sind // Content Element contentElement = element.element(CONTENT_ELEMENT); if (contentElement != null) { String contentType = contentElement.attributeValue(CONTENT_TYPE_ATTR); try { - PadContent content = PadContentRegistry.getPadContentConnect(contentType).newInstance(pad); + Registry<PadContentConnect> padContents = PlayPadPlugin.getRegistryCollection().getPadContents(); + PadContent content = padContents.getComponent(contentType).newInstance(pad); + content.load(contentElement); pad.setContent(content); - } catch (UnkownPadContentException e) { + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block e.printStackTrace(); pad.throwException(null, e); } @@ -147,36 +162,38 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { // Settings Element settingsElement = element.addElement(SETTINGS_ELEMENT); - settingsElement.addElement(VOLUME_ELEMENT).addText(String.valueOf(data.getVolume())); - settingsElement.addElement(LOOP_ELEMENT).addText(String.valueOf(data.isLoop())); - if (data.getTimeMode() != null) - settingsElement.addElement(TIMEMODE_ELEMENT).addText(String.valueOf(data.getTimeMode())); - if (data.isCustomWarning() != false) - data.getWarning().save(settingsElement.addElement(WARNING_ELEMENT)); - if (data.getFade() != null) - data.getFade().save(settingsElement.addElement(FADE_ELEMENT)); + PadSettings padSettings = data.getPadSettings(); + + settingsElement.addElement(VOLUME_ELEMENT).addText(String.valueOf(padSettings.getVolume())); + settingsElement.addElement(LOOP_ELEMENT).addText(String.valueOf(padSettings.isLoop())); + if (padSettings.isCustomTimeMode()) + settingsElement.addElement(TIMEMODE_ELEMENT).addText(String.valueOf(padSettings.getTimeMode())); + if (padSettings.isCustomWarning()) + padSettings.getWarning().save(settingsElement.addElement(WARNING_ELEMENT)); + if (padSettings.isCustomFade()) + padSettings.getFade().save(settingsElement.addElement(FADE_ELEMENT)); // Layout Element layoutsElement = settingsElement.addElement(LAYOUTS_ELEMENT); - layoutsElement.addAttribute(LAYOUT_ACTIVE_ATTR, String.valueOf(data.isCustomLayout())); - for (String layoutType : data.getLayouts().keySet()) { + layoutsElement.addAttribute(LAYOUT_ACTIVE_ATTR, String.valueOf(padSettings.isCustomLayout())); + for (String layoutType : padSettings.getLayouts().keySet()) { Element layoutElement = layoutsElement.addElement(LAYOUT_ELEMENT); layoutElement.addAttribute(LAYOUT_TYPE_ATTR, layoutType); - CartLayout cartLayout = data.getLayouts().get(layoutType); + CartDesign cartLayout = padSettings.getLayouts().get(layoutType); cartLayout.save(layoutElement); } Element userInfoElement = settingsElement.addElement(CUSTOM_SETTINGS_ELEMENT); - for (String key : data.getCustomSettings().keySet()) { + for (String key : padSettings.getCustomSettings().keySet()) { Element itemElement = userInfoElement.addElement(CUSTOM_SETTINGS_ITEM_ELEMENT); - UserDefaults.save(itemElement, data.getCustomSettings().get(key), key); + UserDefaults.save(itemElement, padSettings.getCustomSettings().get(key), key); } // Trigger Element triggersElement = element.addElement("Triggers"); - for (TriggerPoint point : data.getTriggers().keySet()) { - Trigger trigger = data.getTriggers().get(point); + for (TriggerPoint point : padSettings.getTriggers().keySet()) { + Trigger trigger = padSettings.getTriggers().get(point); Element triggerElement = triggersElement.addElement("Trigger"); trigger.save(triggerElement); } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadSettings.java b/PlayWallCore/src/de/tobias/playpad/pad/PadSettings.java new file mode 100644 index 0000000000000000000000000000000000000000..7c46e1ac6437b3ce2eacdf37ca5da79b62969767 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadSettings.java @@ -0,0 +1,208 @@ +package de.tobias.playpad.pad; + +import java.util.HashMap; + +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.registry.DefaultRegistry; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.settings.Fade; +import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.Warning; +import de.tobias.playpad.tigger.Trigger; +import de.tobias.playpad.tigger.TriggerPoint; +import javafx.beans.binding.BooleanBinding; +import javafx.beans.property.BooleanProperty; +import javafx.beans.property.DoubleProperty; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleBooleanProperty; +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleObjectProperty; + +public class PadSettings { + + // Settings + private DoubleProperty volumeProperty = new SimpleDoubleProperty(1.0); + private BooleanProperty loopProperty = new SimpleBooleanProperty(false); + private ObjectProperty<TimeMode> timeModeProperty = new SimpleObjectProperty<>(); + private ObjectProperty<Fade> fadeProperty = new SimpleObjectProperty<>(); + private ObjectProperty<Warning> warningProperty = new SimpleObjectProperty<>(); + + private BooleanProperty customLayoutProperty = new SimpleBooleanProperty(false); + private HashMap<String, CartDesign> layouts = new HashMap<>(); + + private HashMap<TriggerPoint, Trigger> triggers = new HashMap<>(); + + private HashMap<String, Object> customSettings = new HashMap<>(); + + public double getVolume() { + return volumeProperty.get(); + } + + public void setVolume(double volume) { + volumeProperty.set(volume); + } + + public DoubleProperty volumeProperty() { + return volumeProperty; + } + + public boolean isLoop() { + return loopProperty.get(); + } + + public void setLoop(boolean loop) { + this.loopProperty.set(loop); + } + + public BooleanProperty loopProperty() { + return loopProperty; + } + + public boolean isCustomTimeMode() { + return timeModeProperty.isNotNull().get(); + } + + public BooleanBinding customTimeModeProperty() { + return timeModeProperty.isNotNull(); + } + + public TimeMode getTimeMode() { + if (timeModeProperty.isNull().get()) { + if (Profile.currentProfile() != null) { + return Profile.currentProfile().getProfileSettings().getPlayerTimeDisplayMode(); + } + } + return timeModeProperty.get(); + } + + public void setTimeMode(TimeMode timeMode) { + this.timeModeProperty.set(timeMode); + } + + public ObjectProperty<TimeMode> timeModeProperty() { + return timeModeProperty; + } + + public boolean isCustomFade() { + return fadeProperty.isNotNull().get(); + } + + public BooleanBinding customFadeProperty() { + return fadeProperty.isNotNull(); + } + + /** + * Returns either the fade settings of this pad or the global settings + * + * @return Fade + */ + public Fade getFade() { + if (fadeProperty.isNull().get()) { + if (Profile.currentProfile() != null) { + return Profile.currentProfile().getProfileSettings().getFade(); + } + } + return fadeProperty.get(); + } + + public void setFade(Fade fade) { + this.fadeProperty.set(fade); + } + + public ObjectProperty<Fade> fadeProperty() { + return fadeProperty; + } + + public boolean isCustomWarning() { + return warningProperty.isNotNull().get(); + } + + public BooleanBinding customWarningProperty() { + return warningProperty.isNotNull(); + } + + public Warning getWarning() { + if (warningProperty.isNull().get()) { + if (Profile.currentProfile() != null) { + return Profile.currentProfile().getProfileSettings().getWarningFeedback(); + } + } + return warningProperty.get(); + } + + public void setWarning(Warning warning) { + this.warningProperty.set(warning); + } + + public ObjectProperty<Warning> warningProperty() { + return warningProperty; + } + + public boolean isCustomLayout() { + return customLayoutProperty.get(); + } + + public void setCustomLayout(boolean customLayout) { + this.customLayoutProperty.set(customLayout); + } + + public BooleanProperty customLayoutProperty() { + return customLayoutProperty; + } + + public CartDesign getLayout() { + return getLayout(Profile.currentProfile().getProfileSettings().getLayoutType()); + } + + HashMap<String, CartDesign> getLayouts() { + return layouts; + } + + public CartDesign getLayout(String type) { + if (!layouts.containsKey(type)) { + DefaultRegistry<DesignConnect> layouts2 = PlayPadPlugin.getRegistryCollection().getDesigns(); + try { + layouts.put(type, layouts2.getComponent(type).newCartDesign()); + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return layouts.get(type); + } + + public void setLayout(CartDesign layout, String type) { + this.layouts.put(type, layout); + } + + public HashMap<String, Object> getCustomSettings() { + return customSettings; + } + + public HashMap<TriggerPoint, Trigger> getTriggers() { + return triggers; + } + + public Trigger getTrigger(TriggerPoint point) { + return triggers.get(point); + } + + void updateTrigger() { + for (TriggerPoint point : TriggerPoint.values()) { + if (!triggers.containsKey(point)) { + Trigger trigger = new Trigger(point); + triggers.put(point, trigger); + } + } + } + + public boolean hasTriggerItems() { + for (Trigger trigger : triggers.values()) { + if (!trigger.getItems().isEmpty()) + return true; + } + return false; + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadStatusListener.java b/PlayWallCore/src/de/tobias/playpad/pad/PadStatusListener.java index 7b2b24428fa7d99bbf3ada1addbb8c54248ea858..4b35b1dda9738148de908b7ea9e990a397337d82 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadStatusListener.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadStatusListener.java @@ -1,8 +1,10 @@ package de.tobias.playpad.pad; import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.pad.conntent.Fadeable; -import de.tobias.playpad.pad.conntent.Pauseable; +import de.tobias.playpad.pad.conntent.play.Fadeable; +import de.tobias.playpad.pad.conntent.play.Pauseable; +import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileSettings; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; @@ -10,20 +12,37 @@ public class PadStatusListener implements ChangeListener<PadStatus> { private Pad pad; + // Utils für Single Pad Playing + private static Pad currentPlayingPad; // Nur wenn ProfileSettings.isMultiplePlayer == false + public PadStatusListener(Pad pad) { this.pad = pad; } @Override public void changed(ObservableValue<? extends PadStatus> observable, PadStatus oldValue, PadStatus newValue) { + PadSettings padSettings = pad.getPadSettings(); + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + 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 && currentPlayingPad != pad) { + if (currentPlayingPad.getStatus() == PadStatus.PLAY || currentPlayingPad.getStatus() == PadStatus.PAUSE) { + currentPlayingPad.setStatus(PadStatus.STOP); + } + } + currentPlayingPad = pad; + } if (pad.getContent() instanceof Fadeable) { - if (oldValue == PadStatus.PAUSE && pad.getFade().isFadeInPause()) { + if (oldValue == PadStatus.PAUSE && padSettings.getFade().isFadeInPause()) { ((Fadeable) pad.getContent()).fadeIn(); - } else if (pad.getFade().isFadeInStart()) { + } else if (padSettings.getFade().isFadeInStart()) { ((Fadeable) pad.getContent()).fadeIn(); } } @@ -31,7 +50,7 @@ public class PadStatusListener implements ChangeListener<PadStatus> { } } else if (newValue == PadStatus.PAUSE) { if (pad.getContent() instanceof Pauseable) { - if (pad.getContent() instanceof Fadeable && pad.getFade().isFadeOutPause()) { + if (pad.getContent() instanceof Fadeable && padSettings.getFade().isFadeOutPause()) { ((Fadeable) pad.getContent()).fadeOut(() -> { ((Pauseable) pad.getContent()).pause(); @@ -43,9 +62,10 @@ 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() && pad.getFade().isFadeOutStop()) { // Fade nur wenn pad nicht am - // ende ist + if (pad.getContent() instanceof Fadeable && !pad.isEof() && padSettings.getFade().isFadeOutStop()) { // Fade nur wenn Pad + // nicht am ende ist ((Fadeable) pad.getContent()).fadeOut(() -> { pad.getContent().stop(); diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java index 1b5396c72ee4c8f7ba306b159e1656c947bbcb4b..d54338010dd6d7fbfbfff67f804816004e186d3f 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java @@ -1,12 +1,25 @@ 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; +/** + * Verarbeitet den Inhalt eines Pads. Die Einstellungen und der Status ist in Pad ausgelagert. + * + * @author tobias + * + * @version 5.1.0 + * @see Pad + */ public abstract class PadContent { // Refrence @@ -16,9 +29,11 @@ public abstract class PadContent { this.pad = pad; } - public abstract String getType(); + public Pad getPad() { + return pad; + } - public abstract void setMasterVolume(double masterVolume); + public abstract String getType(); public abstract void play(); @@ -26,16 +41,30 @@ public abstract class PadContent { public abstract boolean isPadLoaded(); - public Pad getPad() { - return pad; - } - - public abstract void handlePath(Path path); + /** + * Verarbeitet eien neuen Path für das Pad. + * + * @param path + * 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, IOException; + /** + * Lädt die Medien, sodass sie auf abruf verfügbar sind. + */ public abstract void loadMedia(); + /** + * Entfernt die Medien aus dem Speicher (lässt diese aber im Pad). + */ public abstract void unloadMedia(); + public abstract void setMasterVolume(double masterVolume); + @Override protected void finalize() throws Throwable { unloadMedia(); @@ -60,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/PadContentConnect.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContentConnect.java index c00fd9629838862dbd9d7bfed9ff06c7d04bf5bf..260019495c53a8b7ffa92e95c91dc2cb48d18dff 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContentConnect.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContentConnect.java @@ -6,10 +6,11 @@ import de.tobias.playpad.Displayable; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.view.IPadContentView; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; -import de.tobias.playpad.viewcontroller.SettingsTabViewController; +import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.utils.util.FileUtils; import javafx.scene.layout.Pane; +// COMMENT PadContentConnect public abstract class PadContentConnect implements Comparable<PadContentConnect>, Displayable { public abstract String getType(); @@ -18,7 +19,7 @@ public abstract class PadContentConnect implements Comparable<PadContentConnect> public abstract IPadContentView getPadContentPreview(Pad pad, Pane parentNode); - public SettingsTabViewController getSettingsTabViewController(boolean activePlayer) { + public ProfileSettingsTabViewController getSettingsTabViewController(boolean activePlayer) { return null; } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContentRegistry.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContentRegistry.java deleted file mode 100644 index ce854025b32097ad6f710737dc87db4d23d6eeaf..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContentRegistry.java +++ /dev/null @@ -1,70 +0,0 @@ -package de.tobias.playpad.pad.conntent; - -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -public class PadContentRegistry { - - private static HashMap<String, PadContentConnect> padContents; - - static { - padContents = new HashMap<>(); - } - - public static void registerActionConnect(PadContentConnect connect) { - padContents.put(connect.getType(), connect); - } - - public static PadContentConnect getPadContentConnect(String type) throws UnkownPadContentException { - if (padContents.containsKey(type)) { - return padContents.get(type); - } else { - throw new UnkownPadContentException(type); - } - } - - public static Set<String> getTypes() { - return padContents.keySet(); - } - - public static String getContentTypeForFile(Path path) { - for (String type : padContents.keySet()) { - PadContentConnect connect = padContents.get(type); - String[] fileExtensions = connect.getSupportedTypes(); - for (String fileExtension : fileExtensions) { - if (path.toString().toLowerCase().matches("." + fileExtension)) { - return type; - } - } - } - return null; - } - - public static Set<PadContentConnect> getPadContentConnectsForFile(Path path) throws UnkownPadContentException { - Set<PadContentConnect> connects = new HashSet<>(); - for (String type : PadContentRegistry.getTypes()) { - PadContentConnect connect = PadContentRegistry.getPadContentConnect(type); - for (String extension : connect.getSupportedTypes()) { - if (path.getFileName().toString().toLowerCase().matches("." + extension)) { - connects.add(connect); - } - } - } - return connects; - } - - public static String[] getSupportedFileTypes() { - List<String> extensions = new ArrayList<>(); - for (String type : padContents.keySet()) { - PadContentConnect connect = padContents.get(type); - String[] fileExtensions = connect.getSupportedTypes(); - Collections.addAll(extensions, fileExtensions); - } - return extensions.toArray(new String[extensions.size()]); - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/UnkownPadContentException.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/UnkownPadContentException.java deleted file mode 100644 index dea993db4c6818a650b30272c322ac60eebf7113..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/UnkownPadContentException.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.tobias.playpad.pad.conntent; - -public class UnkownPadContentException extends Exception { - - private static final long serialVersionUID = 1L; - - public UnkownPadContentException(String type) { - super(type); - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/MultiPathContent.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/MultiPathContent.java new file mode 100644 index 0000000000000000000000000000000000000000..e10aa8b85e4e09a56b0e53e810fe03b8700bace9 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/MultiPathContent.java @@ -0,0 +1,11 @@ +package de.tobias.playpad.pad.conntent.path; + +import java.nio.file.Path; +import java.util.List; + +public interface MultiPathContent { + + public List<Path> getPaths(); + + public void clearPaths(); +} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/SinglePathContent.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/SinglePathContent.java new file mode 100644 index 0000000000000000000000000000000000000000..6f9dd3b1887b07e1324502846e9dd6cc826ed326 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/path/SinglePathContent.java @@ -0,0 +1,8 @@ +package de.tobias.playpad.pad.conntent.path; + +import java.nio.file.Path; + +public interface SinglePathContent { + + public Path getPath(); +} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/Durationable.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Durationable.java similarity index 87% rename from PlayWallCore/src/de/tobias/playpad/pad/conntent/Durationable.java rename to PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Durationable.java index 1cde14b76835e8892a79db9e39955e59e07ace7e..65a540c1ec880eb7bed8e984136698beb84adc2c 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/Durationable.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Durationable.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.pad.conntent; +package de.tobias.playpad.pad.conntent.play; import javafx.beans.property.ReadOnlyObjectProperty; import javafx.util.Duration; diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/Fadeable.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Fadeable.java similarity index 74% rename from PlayWallCore/src/de/tobias/playpad/pad/conntent/Fadeable.java rename to PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Fadeable.java index 1f0b54394d418a150a9a9fd938716a2df8591928..5fc99ff4392729b7922e0e5c734abfc6462c0e7b 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/Fadeable.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Fadeable.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.pad.conntent; +package de.tobias.playpad.pad.conntent.play; public interface Fadeable { diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/Pauseable.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Pauseable.java similarity index 55% rename from PlayWallCore/src/de/tobias/playpad/pad/conntent/Pauseable.java rename to PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Pauseable.java index e6250b066e2e066433dffbecee70c26e0432f38e..626570458fb62e6183789990b30543f3d5a2871b 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/Pauseable.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/play/Pauseable.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.pad.conntent; +package de.tobias.playpad.pad.conntent.play; public interface Pauseable { diff --git a/PlayWallCore/src/de/tobias/playpad/pad/drag/PadDragModeRegistery.java b/PlayWallCore/src/de/tobias/playpad/pad/drag/PadDragModeRegistery.java deleted file mode 100644 index 4615abab9070ce7d3a62916a8252635120f51c27..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/pad/drag/PadDragModeRegistery.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.tobias.playpad.pad.drag; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Set; - -public class PadDragModeRegistery { - - private static HashMap<String, PadDragMode> padDragMode; - - static { - padDragMode = new HashMap<>(); - } - - public static void registerActionConnect(PadDragMode mode) { - padDragMode.put(mode.getType(), mode); - } - - public static PadDragMode getPadDragMode(String type) { - if (padDragMode.containsKey(type)) { - return padDragMode.get(type); - } else { - throw new IllegalArgumentException("Tpye of PadDragMode does not exists: " + type); - } - } - - public static Set<String> getTypes() { - return padDragMode.keySet(); - } - - public static Collection<PadDragMode> getValues() { - return padDragMode.values(); - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/listener/IPadPositionListener.java b/PlayWallCore/src/de/tobias/playpad/pad/listener/IPadPositionListener.java new file mode 100644 index 0000000000000000000000000000000000000000..ab6d6bd47d21050005a6c00cc7e814665ee24f85 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/pad/listener/IPadPositionListener.java @@ -0,0 +1,15 @@ +package de.tobias.playpad.pad.listener; + +import de.tobias.playpad.pad.Pad; +import javafx.beans.value.ChangeListener; +import javafx.util.Duration; + +public interface IPadPositionListener extends ChangeListener<Duration> { + + void setPad(Pad pad); + + void setSend(boolean send); + + void stopWaning(); + +} \ No newline at end of file diff --git a/PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerContentListener.java b/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerContentListener.java similarity index 89% rename from PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerContentListener.java rename to PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerContentListener.java index 587e692b04b7dc33b8989e99bdfb2b247f216749..5af0ab7826c370be0c4da8ba667f39363128aadb 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerContentListener.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerContentListener.java @@ -1,8 +1,8 @@ -package de.tobias.playpad.pad.triggerlistener; +package de.tobias.playpad.pad.listener.trigger; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.conntent.Durationable; import de.tobias.playpad.pad.conntent.PadContent; +import de.tobias.playpad.pad.conntent.play.Durationable; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; diff --git a/PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerDurationListener.java b/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerDurationListener.java similarity index 78% rename from PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerDurationListener.java rename to PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerDurationListener.java index 53b3b31a5ae77eec8062346111fbd74419c25147..5307a77818fcfaebdd7ebc1d41ecca3290484a35 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerDurationListener.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerDurationListener.java @@ -1,9 +1,10 @@ -package de.tobias.playpad.pad.triggerlistener; +package de.tobias.playpad.pad.listener.trigger; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.conntent.Durationable; +import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.conntent.PadContent; +import de.tobias.playpad.pad.conntent.play.Durationable; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.tigger.Trigger; import de.tobias.playpad.tigger.TriggerPoint; @@ -30,11 +31,13 @@ public class PadTriggerDurationListener implements ChangeListener<Duration> { IMainViewController mainViewController = PlayPadPlugin.getImplementation().getMainViewController(); Profile currentProfile = Profile.currentProfile(); + PadSettings padSettings = pad.getPadSettings(); - Trigger startTrigger = pad.getTrigger(TriggerPoint.START); + // Execute Triggers + Trigger startTrigger = padSettings.getTrigger(TriggerPoint.START); startTrigger.handle(pad, newValue, pad.getProject(), mainViewController, currentProfile); - Trigger endTrigger = pad.getTrigger(TriggerPoint.EOF_STOP); + Trigger endTrigger = padSettings.getTrigger(TriggerPoint.EOF_STOP); endTrigger.handle(pad, leftTime, pad.getProject(), mainViewController, currentProfile); } } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerStatusListener.java b/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerStatusListener.java similarity index 77% rename from PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerStatusListener.java rename to PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerStatusListener.java index cd0b0dd96e5a0b8a997a22cc8bf72ff84fa6955c..0bb27b286d84c52286513d028a82c93e40b65b36 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/triggerlistener/PadTriggerStatusListener.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerStatusListener.java @@ -1,7 +1,8 @@ -package de.tobias.playpad.pad.triggerlistener; +package de.tobias.playpad.pad.listener.trigger; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.tigger.Trigger; @@ -22,12 +23,15 @@ public class PadTriggerStatusListener implements ChangeListener<PadStatus> { @Override public void changed(ObservableValue<? extends PadStatus> observable, PadStatus oldValue, PadStatus newValue) { if (!pad.isIgnoreTrigger()) { + PadSettings padSettings = pad.getPadSettings(); + + // Execute Trigger if (newValue == PadStatus.PLAY) { // TRIGGER FÜR START - executeTrigger(pad.getTriggers().get(TriggerPoint.START)); + executeTrigger(padSettings.getTriggers().get(TriggerPoint.START)); } else if (newValue == PadStatus.STOP) { // TRIGGER FÜR STOP - executeTrigger(pad.getTriggers().get(TriggerPoint.EOF_STOP)); + executeTrigger(padSettings.getTriggers().get(TriggerPoint.EOF_STOP)); } else if (oldValue == PadStatus.PLAY && newValue == PadStatus.READY && pad.isEof()) { // TRIGGER FÜR EOF - executeTrigger(pad.getTriggers().get(TriggerPoint.EOF_STOP)); + executeTrigger(padSettings.getTriggers().get(TriggerPoint.EOF_STOP)); } } else { pad.setIgnoreTrigger(false); diff --git a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadContentView.java b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadContentView.java index b6cf5186a59491ae0232f1adc78599cabaa5b40c..d2cc68210ef72974fda13e91391e3577e8040d72 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadContentView.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadContentView.java @@ -2,9 +2,31 @@ package de.tobias.playpad.pad.view; import javafx.scene.Node; +// TODO Rename to ContentView +/** + * Schnittstelle für die Vorschau des PadContent eines Pads. + * + * @author tobias + * + * @since 5.1.0 + */ public interface IPadContentView { + /** + * Gibt das GUI Element zurück. + * + * @return GUI Element + */ public Node getNode(); - + + @Deprecated public void unconnect(); + + /** + * Deinitialisiert die View. Hier können mögliche Bindings und Listener entfernt werden. + */ + public default void deinit() { + // TODO Remove the default after remove unconnect from interface + unconnect(); + } } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java new file mode 100644 index 0000000000000000000000000000000000000000..67c3ce99cb1b6a3956df92cea0d6a50783f68d39 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java @@ -0,0 +1,130 @@ +package de.tobias.playpad.pad.view; + +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.viewcontroller.IPadViewController; +import javafx.css.PseudoClass; +import javafx.scene.layout.Pane; + +/** + * Zugriff auf eine PadView. Hier sind alle Methoden um mit der GUI für ein Pad zu agieren. + * + * @author tobias + * + * @since 5.1.0 + * + */ +public interface IPadView { + + /** + * Gibt die aktuelle Vorschau für den Content eines Pads zurück. + * + * @return ContentView + */ + public IPadContentView getContentView(); + + /** + * Setzt die Preview für den PadContent. + * + * @param pad + * Pad + */ + public void setContentView(Pad pad); + + /** + * Gibt den zugehörigen ViewController zu einem Pad zurück. + * + * @return ViewController des Pad + */ + public IPadViewController getViewController(); + + /** + * Gibt das oberste GUI Element zurück, welche im MainView verwendet wird. + * + * @return root node + */ + public Pane getRootNode(); + + /** + * Schaltet den Design Modus für Drag And Drop ein. + * + * @param enable + * true eingeschaltet + */ + public void enableDragAndDropDesignMode(boolean enable); + + /** + * Zeigt ein BusyView über dem Padview an. + * + * @param enable + * true, wird angezeigt + */ + public void showBusyView(boolean enable); + + /** + * Aktiviert eine Pseudoclass für die View + * + * @param playCalss + * Pseudoclass + * @param b + * <code>true</code> Aktiv + */ + public void pseudoClassState(PseudoClass playCalss, boolean b); + + /** + * Setzt den Style für den Root Node der PadView. + * + * @param string + * Style + */ + public void setStyle(String string); + + /** + * Hebt eine Kachel hervor (Beispiel mit einer Animation. + * + * @param milliSecounds + * Dauer in Millisekunden + */ + public void highlightView(int milliSecounds); + + /** + * Aktiviert des Error Labels, damit es angezeigt wird. + * + * @param b + * <code>true</code> Sichtbar + */ + public void setErrorLabelActive(boolean b); + + /** + * Setzt den Fortschritt auf der PlayBar + * + * @param value + * [0, 1] + */ + public void setPlayBarProgress(double value); + + /** + * Setzt die Playbar sichtbar. + * + * @param visible + * <code>true</code> Sichtbar, <code>false</code> nicht sichtbar + */ + public void setPlaybarVisible(boolean visible); + + /** + * Fügt die Standart Elemente der PadView hinzu. Die GUI Element sind Abhängig vom Pad, und welchen Content es hat. + * + * @param pad + * Pad + */ + public void addDefaultElement(Pad pad); + + /** + * Fügt die StyleClasses der PadView hinzu. Die Methode wird vom Controller aufgerufen. + */ + public void applyStyleClasses(int index); + + /** + * Entfernt die StyleClasses vom PadView. Die Methode wird vom Controller aufgerufen. + */ + public void removeStyleClasses(); +} 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 d23f445d42da593d9669807d5e817e0388ae86ee..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadViewController.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.tobias.playpad.pad.view; - -import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.viewcontroller.IPadView; - -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/IPadViewController.java b/PlayWallCore/src/de/tobias/playpad/pad/viewcontroller/IPadViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..563272c8cec50647a64cb38fb109744f09395687 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/pad/viewcontroller/IPadViewController.java @@ -0,0 +1,52 @@ +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.IPadView; +import javafx.beans.value.ChangeListener; +import javafx.util.Duration; + +/** + * Schnittstellen um mit einem PadViewController zu kommunizieren. + * + * @author tobias + * + * @since 5.1.0 + */ +public interface IPadViewController { + + /** + * Gibt das Pad zurück, welches er verwaltet. (Das Datenmodel) + * + * @return Pad + */ + public Pad getPad(); + + /** + * Gibt die View des Controllers zurück. + * + * @return View + */ + public IPadView getView(); + + /** + * Setzt ein Pad für ein View. Hier werden die Datein mittels ViewController der View bekannt gemacht. + * + * @param pad + * Neues Pad + */ + public void setupPad(Pad pad); + + /** + * Entfertn des Verbundene Pad von der View. + */ + public void removePad(); + + public void updateTimeLabel(); + + public void updateButtonDisable(); + + public IPadPositionListener getPadPositionListener(); + + public ChangeListener<Duration> getPadDurationListener(); +} diff --git a/PlayWallCore/src/de/tobias/playpad/plugin/PluginSource.java b/PlayWallCore/src/de/tobias/playpad/plugin/PluginSource.java new file mode 100644 index 0000000000000000000000000000000000000000..48f58baea5ebe8df2cafafa1aa9dd1e36d1a9ab5 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/plugin/PluginSource.java @@ -0,0 +1,39 @@ +package de.tobias.playpad.plugin; + +import java.net.URL; + +/** + * Diese Klasse verwaltet PluginSources, indem sie die URL zu einerm plugin.yml auf einem Server speichert. Das Format für solch eine + * plugin.yml muss folgendes enthalten: version, filename, remotepath, build, dependencies (optional), id. + * + * @author tobias + * + * @since 5.1.0 + * + */ +public class PluginSource { + + private String name; + private URL url; + + /** + * Erstellt eine neues Plugin Quelle. + * + * @param name + * Name der Quelle + * @param url + * Adresse der Quelle + */ + public PluginSource(String name, URL url) { + this.name = name; + this.url = url; + } + + public String getName() { + return name; + } + + public URL getUrl() { + return url; + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/project/Project.java b/PlayWallCore/src/de/tobias/playpad/project/Project.java index f166c6d300916a1308b6a757d67879d4f6284d77..07f36d89fd320ef3579eccdff07d521c3e7e8b2b 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/Project.java +++ b/PlayWallCore/src/de/tobias/playpad/project/Project.java @@ -15,11 +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.playpad.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; @@ -34,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 */ @@ -48,10 +51,15 @@ public class Project { * Liste mit allen Pads. */ private HashMap<Integer, Pad> pads; + + private ProjectSettings settings; + /** * Liste mit den aktuellen Laufzeitfehlern. */ - private ObservableList<PadException> exceptions; + private transient ObservableList<PadException> exceptions; + + private transient IntegerProperty activePlayers; /** * Erstellt ein neues leeres Projekt mit einer Referenz. @@ -62,7 +70,10 @@ public class Project { public Project(ProjectReference ref) { this.ref = ref; this.pads = new HashMap<>(); + this.settings = new ProjectSettings(); + this.exceptions = FXCollections.observableArrayList(); + this.activePlayers = new SimpleIntegerProperty(); } /** @@ -89,6 +100,23 @@ public class Project { return pads.get(index); } + public Pad getPad(int x, int y, int page) { + if (x < settings.getColumns() && y < settings.getRows() && page < settings.getPageCount()) { + int id = (y * settings.getColumns() + x) + page * settings.getColumns() * settings.getRows(); + return getPad(id); + } + return null; + } + + /** + * Gibt die Settings des Projectes zurück + * + * @return + */ + public ProjectSettings getSettings() { + return settings; + } + /** * Erstellt ein neues leeres Pad (mit Referenz zu diesem Projekt) am Index i. * @@ -118,21 +146,24 @@ public class Project { private static final String ROOT_ELEMENT = "Project"; protected static final String PAD_ELEMENT = "Pad"; + private static final String SETTINGS_ELEMENT = "Settings"; public static Project load(ProjectReference ref, boolean loadMedia, ProfileChooseable profileChooseable) - throws DocumentException, IOException, ProfileNotFoundException, ProjectNotFoundException { + throws DocumentException, IOException, ProfileNotFoundException, ProjectNotFoundException, NoSuchComponentException { Path projectPath = ref.getProjectPath(); if (Files.exists(projectPath)) { 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()); } Project project = new Project(ref); + // Lädt Pads XMLHandler<Pad> handler = new XMLHandler<>(projectPath); List<Pad> pads = handler.loadElements(PAD_ELEMENT, new PadSerializer(project)); @@ -142,6 +173,11 @@ public class Project { project.pads.put(pad.getIndex(), pad); } + // Lädt die Einstellungen + Element settingsElement = handler.getRootElement().element(SETTINGS_ELEMENT); + if (settingsElement != null) + project.settings = ProjectSettings.load(settingsElement); + return project; } else { throw new ProjectNotFoundException(ref); @@ -154,9 +190,14 @@ public class Project { Element rootElement = document.addElement(ROOT_ELEMENT); + // Speichern der Pads XMLHandler<Pad> handler = new XMLHandler<>(rootElement); handler.saveElements(PAD_ELEMENT, pads.values(), new PadSerializer()); + // Speichern der Settings + Element settingsElement = rootElement.addElement(SETTINGS_ELEMENT); + settings.save(settingsElement); + if (Files.notExists(projectPath)) { Files.createDirectories(projectPath.getParent()); Files.createFile(projectPath); @@ -168,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 void dereaseActivePlayers() { + if (activePlayers.greaterThan(0).get()) + activePlayers.set(getActivePlayers() - 1); } - public boolean hasPlayedPlayers() { - return getPlayedPlayers() > 0; + public ReadOnlyIntegerProperty activePlayerProperty() { + return activePlayers; } // Exceptions @@ -218,8 +266,33 @@ public class Project { return exceptions; } + // Load Methods + public void loadPadsContent() { + getPads().values().forEach(pad -> + { + try { + pad.loadContent(); + } catch (NoSuchComponentException e) { + e.printStackTrace(); + // TODO handle exception withon project + } + }); + } + @Override public String toString() { return ref.getName() + " (" + ref.getUuid() + ")"; } + + 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 44724c67c6a3815083e9c4eac9bb2b697f63acf9..d69e9cb119cafa29ba63c53f0848dc13f0fcd939 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 new file mode 100644 index 0000000000000000000000000000000000000000..31e1cc9e2a50f208f91ee9065d44a8aa7c44b371 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java @@ -0,0 +1,114 @@ +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; + +public class ProjectSettings { + + public static final int MAX_PAGES = 8; + public static final int MAX_COLUMNS = 10; + public static final int MAX_ROWS = 10; + + @Storable private int pageCount = 2; + @Storable private int columns = 6; + @Storable private int rows = 5; + + private boolean useMediaPath = false; + private Path mediaPath = null; + + public int getPageCount() { + return pageCount; + } + + /** + * Returns the value of colums (Number of cells form left to right) + * + * @return columns + */ + public int getColumns() { + return columns; + } + + /** + * Returns the value of rows (Number of cells from top to bottom + * + * @return rows + */ + public int getRows() { + return rows; + } + + public Path getMediaPath() { + return mediaPath; + } + + public boolean isUseMediaPath() { + return useMediaPath; + } + + public void setPageCount(int pageCount) { + if (pageCount > MAX_PAGES) + pageCount = MAX_PAGES; + this.pageCount = pageCount; + } + + public void setColumns(int columns) { + if (columns > MAX_COLUMNS) + columns = MAX_COLUMNS; + this.columns = columns; + } + + public void setRows(int rows) { + if (rows > MAX_ROWS) + rows = MAX_ROWS; + 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) + settings.setPageCount(Integer.valueOf(element.element(PAGE_COUNT_ELEMENT).getStringValue())); + if (element.element(COLUMNS_ELEMENT) != null) + settings.setColumns(Integer.valueOf(element.element(COLUMNS_ELEMENT).getStringValue())); + 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; + } + + public void save(Element element) { + 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/registry/ComponentRegistry.java b/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..cccd5a8f5e96f649a1d2d2bece319b86bbd0dccf --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java @@ -0,0 +1,85 @@ +package de.tobias.playpad.registry; + +import java.io.IOException; +import java.net.URL; +import java.util.Collection; +import java.util.HashMap; +import java.util.Set; + +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +/** + * Eine Implementierung für eine Registry. + * + * @author tobias + * + * @param <C> + * Componentent + * + * @since 5.1.0 + */ +public class ComponentRegistry<C> implements Registry<C> { + + private HashMap<String, C> components; + private String name; + + public ComponentRegistry(String name) { + components = new HashMap<>(); + this.name = name; + } + + @Override + public void registerComponent(C component, String id) throws IllegalArgumentException { + if (components.containsKey(id)) { + throw new IllegalArgumentException("A components already exists with this id: " + id); + } + components.put(id, component); + System.out.println("Registered: " + name + "#" + id); + } + + @Override + public C getComponent(String id) throws NoSuchComponentException { + if (!components.containsKey(id)) { + throw new NoSuchComponentException(id); + } + return components.get(id); + } + + @Override + public Set<String> getTypes() { + return components.keySet(); + } + + @Override + public Collection<C> getComponents() { + return components.values(); + } + + @Override + public void loadComponentsFromFile(URL url, ClassLoader loader) + throws IOException, DocumentException, ClassNotFoundException, InstantiationException, IllegalAccessException { + if (url == null) { + throw new IOException("URL not found: " + url); + } + SAXReader reader = new SAXReader(); + Document document = reader.read(url); + + Element rootElement = document.getRootElement(); + for (Object obj : rootElement.elements("Component")) { + if (obj instanceof Element) { + Element element = (Element) obj; + String type = element.attributeValue("id"); + + // Find the class of the type + @SuppressWarnings("unchecked") Class<C> clazz = (Class<C>) loader.loadClass(element.getStringValue()); + C component = clazz.newInstance(); + + registerComponent(component, type); + } + } + } + +} diff --git a/PlayWallCore/src/de/tobias/playpad/registry/DefaultComponentRegistry.java b/PlayWallCore/src/de/tobias/playpad/registry/DefaultComponentRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..f085a26114c6048cad549a7b17e7f7e1c6adeaed --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/registry/DefaultComponentRegistry.java @@ -0,0 +1,79 @@ +package de.tobias.playpad.registry; + +import java.io.IOException; +import java.net.URL; + +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +public class DefaultComponentRegistry<C> extends ComponentRegistry<C> implements DefaultRegistry<C> { + + private C defaultValue; + + public DefaultComponentRegistry(String name) { + super(name); + } + + @Override + public C getDefault() { + return defaultValue; + } + + @Override + public String getDefaultID() { + for (String type : getTypes()) { + try { + if (getComponent(type).equals(defaultValue)) { + return type; + } + } catch (NoSuchComponentException e) { + // Exception will never been thrown, because all elements (getTypes()) exists. Otherwise something is totally wrong. + } + } + return null; + } + + @Override + public void setDefault(C component) { + this.defaultValue = component; + } + + @Override + public void setDefaultID(String id) throws NoSuchComponentException { + setDefault(getComponent(id)); + } + + @Override + public void loadComponentsFromFile(URL url, ClassLoader loader) + throws IOException, DocumentException, ClassNotFoundException, InstantiationException, IllegalAccessException { + if (url == null) { + throw new IOException("URL not found: " + url); + } + SAXReader reader = new SAXReader(); + Document document = reader.read(url); + + Element rootElement = document.getRootElement(); + for (Object obj : rootElement.elements("Component")) { + if (obj instanceof Element) { + Element element = (Element) obj; + String type = element.attributeValue("id"); + + // Find the class of the type + @SuppressWarnings("unchecked") Class<C> clazz = (Class<C>) loader.loadClass(element.getStringValue()); + C component = clazz.newInstance(); + + registerComponent(component, type); + + if (element.attributeValue("default") != null) { + String defaultValue = element.attributeValue("default"); + if (defaultValue.equals("true")) { + setDefault(component); + } + } + } + } + } + +} diff --git a/PlayWallCore/src/de/tobias/playpad/registry/DefaultRegistry.java b/PlayWallCore/src/de/tobias/playpad/registry/DefaultRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..527370af19c653afe363d0f0a21b1666f778404d --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/registry/DefaultRegistry.java @@ -0,0 +1,20 @@ +package de.tobias.playpad.registry; + +/** + * Zusätzliche Methoden Definitionen für eine Registry, die einen Default Wert braucht. + * + * @author tobias - s0553746 + * + * @param <C> Type der Daten + */ +public interface DefaultRegistry<C> extends Registry<C> { + + public C getDefault(); + + public String getDefaultID(); + + public void setDefault(C component); + + public void setDefaultID(String id) throws NoSuchComponentException; + +} diff --git a/PlayWallCore/src/de/tobias/playpad/registry/NoSuchComponentException.java b/PlayWallCore/src/de/tobias/playpad/registry/NoSuchComponentException.java new file mode 100644 index 0000000000000000000000000000000000000000..bc80b542fef48b68465dceeee7f3576bb0d4ef8a --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/registry/NoSuchComponentException.java @@ -0,0 +1,10 @@ +package de.tobias.playpad.registry; + +public class NoSuchComponentException extends Exception { + + private static final long serialVersionUID = 1L; + + public NoSuchComponentException(String id) { + super("No component for id: " + id); + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/registry/Registry.java b/PlayWallCore/src/de/tobias/playpad/registry/Registry.java new file mode 100644 index 0000000000000000000000000000000000000000..74fe650f172da5b046918e653534dd56613ee6af --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/registry/Registry.java @@ -0,0 +1,43 @@ +package de.tobias.playpad.registry; + +import java.util.Collection; +import java.util.Set; + +/** + * Dieses Interface definiert Methoden bei Arbeit mit Komponenten, die durch Plugins zum Programm hinzugefügt werden können. + * + * @author tobias + * + * @param <C> + * Component + * + * @since 5.1.0 + */ +public interface Registry<C> extends WriteOnlyRegistry<C> { + + /** + * Gibt eine Komponenten zu einer ID zurück. + * + * @param id + * ID der Komponenten + * @return Komponente + * + * @throws NoSuchComponentException + * Wird geworfen, wenn die Komponente nicht existiert. + */ + public C getComponent(String id) throws NoSuchComponentException; + + /** + * Listet alle Type ID auf, die registriert wurden. + * + * @return Liste mit IDs + */ + public Set<String> getTypes(); + + /** + * Listet alle Implementierungen auf. + * + * @return Implementierungen + */ + public Collection<C> getComponents(); +} diff --git a/PlayWallCore/src/de/tobias/playpad/registry/WriteOnlyRegistry.java b/PlayWallCore/src/de/tobias/playpad/registry/WriteOnlyRegistry.java new file mode 100644 index 0000000000000000000000000000000000000000..8a6f8859539d0734ff7b0899f973c38974a5a582 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/registry/WriteOnlyRegistry.java @@ -0,0 +1,62 @@ +package de.tobias.playpad.registry; + +import java.io.IOException; +import java.net.URL; + +import org.dom4j.DocumentException; + +/** + * Eine Schnittstelle um Komponenten zu registrieren, aber nicht auszulesen. + * + * @author tobias + * + * @param <C> + * Component + * + * @since 5.1.0 + */ +public interface WriteOnlyRegistry<C> { + + /** + * Registriert eine Komponente zu einer ID. + * + * @param component + * Komponente + * @param id + * ID + * @throws IllegalArgumentException + * Die Komponete gibt es bereits. + */ + public void registerComponent(C component, String id) throws IllegalArgumentException; + + /** + * Lädt aus einer XML Datei die Komponenten Deklaration und registriert diese automatisch. + * + * @param url + * URL zur Deklaration + * @param loader + * ClassLoader + * @throws IOException + * Fehler beim Laden der Datei. + * @throws DocumentException + * Fehler beim Laden des XML Documents + * @throws ClassNotFoundException + * Die Klasse wurde nicht gefunden + * @throws IllegalAccessException + * Unerlaubte Sichtbarkeit + * @throws InstantiationException + * Die Klasse konnte nicht instanziert werden + */ + public void loadComponentsFromFile(URL url, ClassLoader loader) + throws IOException, DocumentException, ClassNotFoundException, InstantiationException, IllegalAccessException; + + public default void loadComponentsFromFile(String name) + throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, DocumentException { + loadComponentsFromFile(getClass().getClassLoader().getResource(name), getClass().getClassLoader()); + } + + public default void loadComponentsFromFile(String name, ClassLoader loader) + throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, DocumentException { + loadComponentsFromFile(loader.getResource(name), loader); + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..3caa9fa0d669543ae5b71f6e3b9734c14f5a2233 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/settings/GlobalSettings.java @@ -0,0 +1,263 @@ +package de.tobias.playpad.settings; + +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; +import org.dom4j.DocumentHelper; +import org.dom4j.Element; +import org.dom4j.io.OutputFormat; +import org.dom4j.io.SAXReader; +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. + * + * @author tobias + * + * @since 5.1.0 + * + * @see PlayPad#getGlobalSettings() + * + */ +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; + } + + public UpdateChannel getUpdateChannel() { + 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; + } + + public void setUpdateChannel(UpdateChannel updateChannel) { + 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. + * + * @return GlobalSettings + * @throws DocumentException + * XML Fehler + * @throws IOException + * Fehler bei IO + */ + public static GlobalSettings load(Path savePath) throws DocumentException, IOException { + GlobalSettings settings = new GlobalSettings(); + settings.savePath = savePath; + + if (Files.exists(savePath)) { + SAXReader reader = new SAXReader(); + Document document = reader.read(Files.newInputStream(savePath)); + Element root = document.getRootElement(); + + if (root.element(KEYS_ELEMENT) != null) + settings.keyCollection.load(root.element(KEYS_ELEMENT)); + + if (root.element(AUTO_UPDATE_ELEMENT) != null) { + 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; + } + + /** + * Speichert die Globalen Einstellungen + * + * @throws UnsupportedEncodingException + * Fehler bei XML + * @throws IOException + * Fehler bei IO + */ + public void save() throws UnsupportedEncodingException, IOException { + Document document = DocumentHelper.createDocument(); + Element root = document.addElement("Config"); + + // Keys + Element keyCollectionElement = root.addElement(KEYS_ELEMENT); + keyCollection.save(keyCollectionElement); + + // 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 7e55988c26d8adbfa59e1b5494c3766d760595dd..2516305ee7b7e610aa892aeb91666cbbbabcd942 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java @@ -12,8 +12,10 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.action.MappingList; -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.playpad.layout.LayoutRegistry; +import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.design.GlobalDesign; +import de.tobias.playpad.registry.DefaultRegistry; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; @@ -24,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; @@ -34,7 +36,7 @@ public class Profile { private ProfileSettings profileSettings; private MappingList mappings; - private HashMap<String, GlobalLayout> layouts; + private HashMap<String, GlobalDesign> layouts; Profile(ProfileReference ref) { this.ref = ref; @@ -63,21 +65,28 @@ public class Profile { listeners.forEach(listener -> listener.reloadSettings(old, currentProfile)); } - public HashMap<String, GlobalLayout> getLayouts() { + public HashMap<String, GlobalDesign> getLayouts() { return layouts; } - public GlobalLayout getLayout(String type) { + public GlobalDesign getLayout(String type) { if (layouts.containsKey(type)) { return layouts.get(type); } else { - GlobalLayout layout = LayoutRegistry.getLayout(type).newGlobalLayout(); - layouts.put(type, layout); - return layout; + try { + DefaultRegistry<DesignConnect> registry = PlayPadPlugin.getRegistryCollection().getDesigns(); + GlobalDesign layout = registry.getComponent(type).newGlobalDesign(); + layouts.put(type, layout); + return layout; + } catch (NoSuchComponentException e) { // -> Throw exception + // TODO Error Handling + e.printStackTrace(); + } } + return null; } - public GlobalLayout currentLayout() { + public GlobalDesign currentLayout() { return getLayout(profileSettings.getLayoutType()); } @@ -102,7 +111,7 @@ public class Profile { if (Files.exists(app.getPath(PathType.CONFIGURATION, ref.getFileName()))) { ProfileSettings profileSettings = ProfileSettings.load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), PROFILE_SETTINGS_XML)); - HashMap<String, GlobalLayout> layouts = GlobalLayout + HashMap<String, GlobalDesign> layouts = GlobalDesign .loadGlobalLayout(app.getPath(PathType.CONFIGURATION, ref.getFileName(), LAYOUT_XML)); profile.profileSettings = profileSettings; @@ -146,7 +155,7 @@ public class Profile { profileSettings.save(getProfilePath(PROFILE_SETTINGS_XML)); mappings.save(getProfilePath(MAPPING_XML)); - GlobalLayout.saveGlobal(layouts, getProfilePath(LAYOUT_XML)); + GlobalDesign.saveGlobal(layouts, getProfilePath(LAYOUT_XML)); } private Path getProfilePath(String fileName) { diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java index ba3a13d08fed86e8553a404235e11a69e8c57d3b..c50d17723c8fb442c96fb1e6851b753c0eede9cd 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java @@ -103,7 +103,8 @@ public class ProfileReference implements Displayable { * Sucht eine Referenz zu einer UUID raus. * * @param profile - * @return + * UUID des Profiles + * @return ProfileReferenz für die UUID */ public static ProfileReference getReference(UUID profile) { for (ProfileReference ref : profiles) { @@ -128,8 +129,9 @@ public class ProfileReference implements Displayable { * * @param name * Profile Name - * @return + * @return Referenz auf das neue Profile. * @throws UnsupportedEncodingException + * Fehler beim Speichern des XML * @throws IOException * IO Fehler */ @@ -283,7 +285,8 @@ public class ProfileReference implements Displayable { * Gibt einen Pfad für einen Dateinamen in diesem Profile zurück. * * @param name - * @return + * Name der Datei + * @return Path für die Datei */ public Path getCustomFilePath(String name) { return ApplicationUtils.getApplication().getPath(PathType.CONFIGURATION, getFileName(), name); diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java index 9189fb33224213e3ba3a70be6b65029f6aa29baf..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; @@ -15,12 +14,8 @@ import org.dom4j.io.OutputFormat; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; -import de.tobias.playpad.audio.AudioRegistry; -import de.tobias.playpad.layout.LayoutRegistry; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.TimeMode; -import de.tobias.playpad.update.UpdateChannel; -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; @@ -34,34 +29,25 @@ public class ProfileSettings implements SettingsSerializable { private static final long serialVersionUID = 1L; - public static final int MAX_PAGES = 8; - @Storable private BooleanProperty lockedProperty = new SimpleBooleanProperty(false); // MIDI @Storable private String midiDevice; - - // GridPane - @Storable private int pageCount = 2; - @Storable private int columns = 6; - @Storable private int rows = 5; + @Storable private boolean midiActive = false; // Audio Output - @Storable private String audioClass = AudioRegistry.getDefaultAudioInterface(); + @Storable private String audioClass = PlayPadPlugin.getRegistryCollection().getAudioHandlers().getDefaultID(); @Storable private HashMap<String, Object> audioUserInfo = new HashMap<>(); // Layout - @Storable private String layoutType = LayoutRegistry.getDefaultLayout(); + @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; @@ -69,13 +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); - - // Update - TODO GlobalSettings - @Storable private boolean autoUpdate = true; - @Storable private UpdateChannel updateChannel = UpdateChannel.STABLE; - public boolean isLocked() { return lockedProperty.get(); } @@ -93,36 +72,14 @@ public class ProfileSettings implements SettingsSerializable { return midiDevice; } - public int getPageCount() { - return pageCount; - } - - /** - * Returns the value of colums (Number of cells form left to right) - * - * @return columns - */ - public int getColumns() { - return columns; - } - - /** - * Returns the value of rows (Number of cells from top to bottom - * - * @return rows - */ - public int getRows() { - return rows; - } - - public Path getCachePath() { - return cachePath; - } - public String getLayoutType() { return layoutType; } + public String getMainLayoutType() { + return mainLayoutType; + } + public Warning getWarningFeedback() { return warningFeedback; } @@ -131,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(); } @@ -175,12 +112,8 @@ public class ProfileSettings implements SettingsSerializable { return audioUserInfo; } - public boolean isAutoUpdate() { - return autoUpdate; - } - - public UpdateChannel getUpdateChannel() { - return updateChannel; + public boolean isMultiplePlayer() { + return multiplePlayer; } // Setter @@ -188,28 +121,14 @@ public class ProfileSettings implements SettingsSerializable { this.midiDevice = midiDevice; } - public void setPageCount(int pageCount) { - if (pageCount > MAX_PAGES) - pageCount = MAX_PAGES; - this.pageCount = pageCount; - } - - public void setColumns(int columns) { - this.columns = columns; - } - - public void setRows(int rows) { - this.rows = rows; - } - - public void setCachePath(Path cachePath) { - this.cachePath = cachePath; - } - public void setLayoutType(String layoutType) { this.layoutType = layoutType; } + public void setMainLayoutType(String mainLayoutType) { + this.mainLayoutType = mainLayoutType; + } + public void setWarningFeedback(Warning warningFeedback) { this.warningFeedback = warningFeedback; } @@ -218,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); } @@ -258,12 +157,8 @@ public class ProfileSettings implements SettingsSerializable { this.audioClass = audioClass; } - public void setAutoUpdate(boolean autoUpdate) { - this.autoUpdate = autoUpdate; - } - - public void setUpdateChannel(UpdateChannel updateChannel) { - this.updateChannel = updateChannel; + public void setMultiplePlayer(boolean multiplePlayer) { + this.multiplePlayer = multiplePlayer; } // Properties @@ -273,26 +168,17 @@ public class ProfileSettings implements SettingsSerializable { private static final String LOCKED_ELEMENT = "Locked"; private static final String ITEM_ELEMENT = "Item"; - private static final String AUTO_UPDATE_ELEMENT = "AutoUpdate"; - private static final String UPDATE_CHANNEL_ELEMENT = "UpdateChannel"; - 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 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 MULTIPLE_PLAYER_ELEMENT = "MultiplePlayer"; private static final String TIME_DISPLAY_ELEMENT = "TimeDisplay"; private static final String FADE_ELEMENT = "Fade"; private static final String WARNING_ELEMENT = "Warning"; private static final String LAYOUT_TYPE_ELEMENT = "LayoutType"; - 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 MAIN_LAYOUT_TYPE_ELEMENT = "MainLayoutType"; private static final String MIDI_ACTIVE_ELEMENT = "MidiActive"; private static final String MIDI_DEVICE_ELEMENT = "MidiDevice"; @@ -312,16 +198,16 @@ public class ProfileSettings implements SettingsSerializable { if (root.element(MIDI_ACTIVE_ELEMENT) != null) profileSettings.setMidiActive(Boolean.valueOf(root.element(MIDI_ACTIVE_ELEMENT).getStringValue())); - if (root.element(PAGE_COUNT_ELEMENT) != null) - profileSettings.setPageCount(Integer.valueOf(root.element(PAGE_COUNT_ELEMENT).getStringValue())); - if (root.element(COLUMNS_ELEMENT) != null) - profileSettings.setColumns(Integer.valueOf(root.element(COLUMNS_ELEMENT).getStringValue())); - if (root.element(ROWS_ELEMENT) != null) - profileSettings.setRows(Integer.valueOf(root.element(ROWS_ELEMENT).getStringValue())); - if (root.element(LAYOUT_TYPE_ELEMENT) != null) { profileSettings.setLayoutType(root.element(LAYOUT_TYPE_ELEMENT).getStringValue()); } + if (root.element(MAIN_LAYOUT_TYPE_ELEMENT) != null) { + profileSettings.setMainLayoutType(root.element(MAIN_LAYOUT_TYPE_ELEMENT).getStringValue()); + } + + if (root.element(MULTIPLE_PLAYER_ELEMENT) != null) { + profileSettings.setMultiplePlayer(Boolean.valueOf(root.element(MULTIPLE_PLAYER_ELEMENT).getStringValue())); + } if (root.element(WARNING_ELEMENT) != null) { Warning warning = Warning.load(root.element(WARNING_ELEMENT)); @@ -344,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) @@ -379,18 +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())); - } - - if (root.element(AUTO_UPDATE_ELEMENT) != null) { - profileSettings.setAutoUpdate(Boolean.valueOf(root.element(AUTO_UPDATE_ELEMENT).getStringValue())); - } - - if (root.element(UPDATE_CHANNEL_ELEMENT) != null) { - profileSettings.setUpdateChannel(UpdateChannel.valueOf(root.element(UPDATE_CHANNEL_ELEMENT).getStringValue())); - } } return profileSettings; } @@ -406,23 +263,14 @@ public class ProfileSettings implements SettingsSerializable { root.addElement(MIDI_DEVICE_ELEMENT).addText(midiDevice); root.addElement(MIDI_ACTIVE_ELEMENT).addText(String.valueOf(midiActive)); - // GirdPane - root.addElement(PAGE_COUNT_ELEMENT).addText(String.valueOf(pageCount)); - root.addElement(COLUMNS_ELEMENT).addText(String.valueOf(columns)); - root.addElement(ROWS_ELEMENT).addText(String.valueOf(rows)); - root.addElement(LAYOUT_TYPE_ELEMENT).addText(layoutType); + root.addElement(MAIN_LAYOUT_TYPE_ELEMENT).addText(mainLayoutType); warningFeedback.save(root.addElement(WARNING_ELEMENT)); fade.save(root.addElement(FADE_ELEMENT)); root.addElement(TIME_DISPLAY_ELEMENT).addText(player_timeDisplayMode.name()); - 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(MULTIPLE_PLAYER_ELEMENT).addText(String.valueOf(multiplePlayer)); root.addElement(WINDOW_ALWAYS_ON_TOP_ELEMENT).addText(String.valueOf(windowAlwaysOnTop)); @@ -435,13 +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()); - - // Update - root.addElement(AUTO_UPDATE_ELEMENT).addText(String.valueOf(autoUpdate)); - root.addElement(UPDATE_CHANNEL_ELEMENT).addText(updateChannel.name()); - XMLWriter writer = new XMLWriter(Files.newOutputStream(path), OutputFormat.createPrettyPrint()); writer.write(document); writer.close(); diff --git a/PlayWallCore/src/de/tobias/playpad/settings/keys/Key.java b/PlayWallCore/src/de/tobias/playpad/settings/keys/Key.java new file mode 100644 index 0000000000000000000000000000000000000000..7ae9e3c5bf7f7a64ef8970e00bf2fe5efc5f8bee --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/settings/keys/Key.java @@ -0,0 +1,125 @@ +package de.tobias.playpad.settings.keys; + +import de.tobias.playpad.Displayable; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; +import javafx.scene.input.KeyCombination; + +public class Key implements Displayable { + + private String id; + + private String key; + private boolean ctrl; + private boolean alt; + private boolean meta; + private boolean shift; + + public Key(String id) { + this.id = id; + } + + public Key(String id, String key, boolean ctrl, boolean alt, boolean meta, boolean shift) { + this.id = id; + + this.key = key; + this.ctrl = ctrl; + this.alt = alt; + this.meta = meta; + this.shift = shift; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + + displayProperty.set(toString()); + } + + public boolean isCtrl() { + return ctrl; + } + + public void setCtrl(boolean ctrl) { + this.ctrl = ctrl; + + displayProperty.set(toString()); + } + + public boolean isAlt() { + return alt; + } + + public void setAlt(boolean alt) { + this.alt = alt; + + displayProperty.set(toString()); + } + + public boolean isMeta() { + return meta; + } + + public void setMeta(boolean meta) { + this.meta = meta; + + displayProperty.set(toString()); + } + + public boolean isShift() { + return shift; + } + + public void setShift(boolean shift) { + this.shift = shift; + + displayProperty.set(toString()); + } + + public String getId() { + return id; + } + + public String getKeyCode() { + StringBuilder builder = new StringBuilder(); + + if (ctrl) + builder.append("ctrl+"); + + if (alt) + builder.append("alt+"); + + if (meta) + builder.append("meta+"); + + if (shift) + builder.append("shift+"); + + builder.append(key); + + return builder.toString(); + } + + @Override + public String toString() { + if (!getKeyCode().isEmpty()) + try { + return KeyCombination.valueOf(getKeyCode()).getDisplayText(); + } catch (IllegalArgumentException e) { + return ""; + } + else + return ""; + } + + private StringProperty displayProperty = new SimpleStringProperty(); + + @Override + public StringProperty displayProperty() { + displayProperty.set(toString()); + return displayProperty; + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/settings/keys/KeyCollection.java b/PlayWallCore/src/de/tobias/playpad/settings/keys/KeyCollection.java new file mode 100644 index 0000000000000000000000000000000000000000..85518577e5cff024333007fdca3a82db9d375e76 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/settings/keys/KeyCollection.java @@ -0,0 +1,155 @@ +package de.tobias.playpad.settings.keys; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.ResourceBundle; + +import org.dom4j.Document; +import org.dom4j.DocumentException; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; + +import de.tobias.playpad.xml.XMLHandler; +import de.tobias.utils.util.OS; + +/** + * Verwaltung der Tastenkombinationen für das Menu. + * + * @author tobias + * + * @since 5.1.0 + */ +public class KeyCollection { + + // Schlüssel: ID, Value: Key + private HashMap<String, Key> keys; + private HashMap<String, String> names; + + public KeyCollection() { + keys = new HashMap<>(); + names = new HashMap<>(); + } + + public void register(Key key) { + if (!keys.containsKey(key.getId())) { + if (!keysConflict(key)) { + keys.put(key.getId(), key); + } + } + } + + public String getName(String id) { + return names.get(id); + } + + public Key getKey(String id) { + return keys.get(id); + } + + public Collection<Key> getKeys() { + return keys.values(); + } + + /** + * Löscht eine Tastenkombination. + * + * @param key + * Key + */ + public void removeKeyBinding(Key key) { + key.setAlt(false); + key.setCtrl(false); + key.setMeta(false); + key.setShift(false); + key.setKey(""); + } + + public boolean keysConflict(Key key) { + for (Key k : keys.values()) { + if (k.getKeyCode().equals(key.getKeyCode())) { + return true; + } + } + 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"; + + public void load(Element element) { + XMLHandler<Key> handler = new XMLHandler<>(element); + List<Key> keys = handler.loadElements(KEY_ELEMENT, new KeySerializer()); + for (Key key : keys) { + register(key); + } + } + + public void save(Element element) { + XMLHandler<Key> handler = new XMLHandler<>(element); + handler.saveElements(KEY_ELEMENT, getKeys(), new KeySerializer()); + } + + private static final String WINDOWS_KEYS = "Windows"; + private static final String MAC_KEYS = "Mac"; + + public void loadDefaultFromFile(String classPath, ResourceBundle bundle) { + SAXReader reader = new SAXReader(); + try { + Document document = reader.read(getClass().getClassLoader().getResourceAsStream(classPath)); + Element rootElement = document.getRootElement(); + + Element keysElement = null; + if (OS.isWindows()) + keysElement = rootElement.element(WINDOWS_KEYS); + else if (OS.isMacOS()) + keysElement = rootElement.element(MAC_KEYS); + + if (keysElement != null) { + KeySerializer keySerializer = new KeySerializer(); + + for (Object obj : keysElement.elements(KEY_ELEMENT)) { + if (obj instanceof Element) { + Element keyElement = (Element) obj; + + String name = loadName(keyElement, bundle); + Key key = keySerializer.loadElement(keyElement); + + names.put(key.getId(), name); + register(key); + } + } + } + } catch (DocumentException e) { + e.printStackTrace(); + } + } + + private String loadName(Element element, ResourceBundle bundle) { + String name = element.attributeValue("name"); + if (name != null) { + return bundle.getString(name); + } + return null; + } + + public void editKey(Key newKey) { + Key savedKey = getKey(newKey.getId()); + + savedKey.setAlt(newKey.isAlt()); + savedKey.setCtrl(newKey.isCtrl()); + savedKey.setMeta(newKey.isMeta()); + savedKey.setShift(newKey.isShift()); + savedKey.setKey(newKey.getKey()); + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/settings/keys/KeySerializer.java b/PlayWallCore/src/de/tobias/playpad/settings/keys/KeySerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..cb8e7fc7a9d30c60e6b56f769758fe81fd05e391 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/settings/keys/KeySerializer.java @@ -0,0 +1,57 @@ +package de.tobias.playpad.settings.keys; + +import org.dom4j.Element; + +import de.tobias.playpad.xml.XMLDeserializer; +import de.tobias.playpad.xml.XMLSerializer; + +public class KeySerializer implements XMLSerializer<Key>, XMLDeserializer<Key> { + + private static final String ID_ATTR = "id"; + private static final String KEY_ATTR = "key"; + private static final String ALT_ATTR = "alt"; + private static final String CTRL_ATTR = "ctrl"; + private static final String META_ATTR = "meta"; + private static final String SHIFT_ATTR = "shift"; + + public Key loadElement(Element element) { + boolean shift = false; + if (element.attributeValue(SHIFT_ATTR) != null) { + shift = Boolean.valueOf(element.attributeValue(SHIFT_ATTR)); + } + boolean meta = false; + if (element.attributeValue(META_ATTR) != null) { + meta = Boolean.valueOf(element.attributeValue(META_ATTR)); + } + boolean ctrl = false; + if (element.attributeValue(CTRL_ATTR) != null) { + ctrl = Boolean.valueOf(element.attributeValue(CTRL_ATTR)); + } + boolean alt = false; + if (element.attributeValue(ALT_ATTR) != null) { + alt = Boolean.valueOf(element.attributeValue(ALT_ATTR)); + } + + String key = ""; + if (element.attributeValue(KEY_ATTR) != null) { + key = element.attributeValue(KEY_ATTR); + } + + String id = ""; + if (element.attributeValue(ID_ATTR) != null) { + id = element.attributeValue(ID_ATTR); + } + + return new Key(id, key, ctrl, alt, meta, shift); + } + + @Override + public void saveElement(Element newElement, Key data) { + newElement.addAttribute(SHIFT_ATTR, String.valueOf(data.isShift())); + newElement.addAttribute(META_ATTR, String.valueOf(data.isMeta())); + newElement.addAttribute(CTRL_ATTR, String.valueOf(data.isCtrl())); + newElement.addAttribute(ALT_ATTR, String.valueOf(data.isAlt())); + newElement.addAttribute(KEY_ATTR, data.getKey()); + newElement.addAttribute(ID_ATTR, data.getId()); + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/tigger/Trigger.java b/PlayWallCore/src/de/tobias/playpad/tigger/Trigger.java index e6c84edf666fbafe345f06136114394f43f332b6..924e6010ac208363794f1ded976d2062f81ce9a4 100644 --- a/PlayWallCore/src/de/tobias/playpad/tigger/Trigger.java +++ b/PlayWallCore/src/de/tobias/playpad/tigger/Trigger.java @@ -6,9 +6,12 @@ import java.util.List; import org.dom4j.Element; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; 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; import javafx.util.Duration; @@ -62,10 +65,17 @@ public class Trigger { if (itemObj instanceof Element) { Element itemElement = (Element) itemObj; String type = itemElement.attributeValue(TYPE_ATTR); - TriggerItemConnect connect = TriggerRegistry.getTriggerConnect(type); - TriggerItem item = connect.newInstance(this); - item.load(itemElement); - items.add(item); + + Registry<TriggerItemConnect> registry = PlayPadPlugin.getRegistryCollection().getTriggerItems(); + try { + TriggerItemConnect connect = registry.getComponent(type); + TriggerItem item = connect.newInstance(this); + item.load(itemElement); + items.add(item); + } catch (NoSuchComponentException e) { + e.printStackTrace(); + // TODO Error Handling + } } } } diff --git a/PlayWallCore/src/de/tobias/playpad/tigger/TriggerItem.java b/PlayWallCore/src/de/tobias/playpad/tigger/TriggerItem.java index 9fe601a389ad0a822df722e0a69906367a61fa6e..496a00b4c0d4233db96765c1f5f6f3ec736603c6 100644 --- a/PlayWallCore/src/de/tobias/playpad/tigger/TriggerItem.java +++ b/PlayWallCore/src/de/tobias/playpad/tigger/TriggerItem.java @@ -50,6 +50,7 @@ public abstract class TriggerItem { * You must call super.load * * @param element + * XML Element */ public void load(Element element) { if (element.attributeValue(DURATION_ATTR) != null) { @@ -61,6 +62,7 @@ public abstract class TriggerItem { * You must call super.save * * @param element + * XMl Element */ public void save(Element element) { element.addAttribute(DURATION_ATTR, String.valueOf(durationFromPoint.toMillis())); diff --git a/PlayWallCore/src/de/tobias/playpad/tigger/TriggerRegistry.java b/PlayWallCore/src/de/tobias/playpad/tigger/TriggerRegistry.java deleted file mode 100644 index 116ed5463ff37e6ea59501f49dfab3daf2d320f7..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/tigger/TriggerRegistry.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.tobias.playpad.tigger; - -import java.util.HashMap; -import java.util.Set; - -public class TriggerRegistry { - - private static HashMap<String, TriggerItemConnect> triggers = new HashMap<>();; - - public static void register(TriggerItemConnect connect) { - triggers.put(connect.getType(), connect); - } - - public static TriggerItemConnect getTriggerConnect(String type) { - if (triggers.containsKey(type)) { - return triggers.get(type); - } - return null; - } - - public static Set<String> getTypes() { - return triggers.keySet(); - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java b/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java new file mode 100644 index 0000000000000000000000000000000000000000..b8a88aa78514af5227bfe7290a8ff84d780ff548 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java @@ -0,0 +1,66 @@ +package de.tobias.playpad.view.main; + +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; + +/** + * Dieses Interface beschreibt die Bestandteile des Layouts (GUI Elemente) des Main Views. + * + * @author tobias + * + * @since 5.1.0 + */ +public interface MainLayoutConnect { + + /** + * Gibt den Unique Identifier zurück. + * + * @return ID + */ + public String getType(); + + /** + * Gibt einen lesbaren (am besten Localized) Namen für den Nutzer zurück. + * + * @return Name + */ + public String name(); + + /** + * Erstellt einen ViewController für die Menu/Toolbar Fläche. + * + * @param mainViewRef + * Refernz auf den Main View + * + * @return Neuer ViewController mit View + */ + public MenuToolbarViewController createMenuToolbar(IMainViewController mainViewRef); + + /** + * Erstellt ein neues Pad mit einem ViewController + * + * @return Pad + * + * @see IPadView notwendige Methoden für ein Pad + * @see IPadViewController ViewController zum Pad + */ + public IPadView createPadView(); + + /** + * Recycelt eine PadView, damit nicht immer neue erstellt werden müssen. + * + * @param padView + * alte PadView + */ + public void recyclePadView(IPadView padView); + + /** + * Gibt das Layout sepzifische Stylesheet zurück. + * + * @return path in jar + */ + public String getStylesheet(); + +} diff --git a/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutHandler.java b/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..4c94753baf1ed882c45f8305e1e3b4ce6b5a2b70 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutHandler.java @@ -0,0 +1,29 @@ +package de.tobias.playpad.view.main; + +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; + +/** + * Schnittstelle für das Handle einer neunen Toolbar. Diese Methode wird vom MainView automatisch bei einem neuen Layout aufgeführt. + * + * @author tobias + * + * @since 5.1.0 + * + * @see IMainViewController#performLayoutDependendAction(MainLayoutHandler) + * @see MainLayoutConnect + */ +@FunctionalInterface +public interface MainLayoutHandler { + + /** + * Listener Methode für den Wechsel der Toolbar. + * + * @param oldToolbar + * Alte Toolbar + * @param newToolbar + * Neue Toolbar + */ + public void handle(MenuToolbarViewController oldToolbar, MenuToolbarViewController newToolbar); + +} diff --git a/PlayWallCore/src/de/tobias/playpad/view/main/MenuType.java b/PlayWallCore/src/de/tobias/playpad/view/main/MenuType.java new file mode 100644 index 0000000000000000000000000000000000000000..14080aec095ee64fe3c2d589a486cf754a4b7d5a --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/view/main/MenuType.java @@ -0,0 +1,6 @@ +package de.tobias.playpad.view.main; + +public enum MenuType { + + EXTENSION, +} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioHandlerViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioHandlerViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..ba5e4d0af5824208ba515155ddd68e2fe7a70397 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioHandlerViewController.java @@ -0,0 +1,37 @@ +package de.tobias.playpad.viewcontroller; + +import java.util.ResourceBundle; + +import de.tobias.playpad.audio.AudioHandlerConnect; +import de.tobias.utils.ui.ContentViewController; + +/** + * Einstellungen ViewController für einen sAudio Handler. + * + * @author tobias + * + * @see AudioHandlerConnect + */ +public abstract class AudioHandlerViewController extends ContentViewController { + + /** + * Neuer ViewController. + * + * @param name + * Name der FXML + * @param path + * Path zur FXML (ohne Dateiname) + * @param localization + * Localization + */ + public AudioHandlerViewController(String name, String path, ResourceBundle localization) { + super(name, path, localization); + } + + /** + * Prüft ob die Einstellungen geändert wurden. + * + * @return <code>true</code> Audio Einstellungen für Pads werden automatisch neu geladen + */ + public abstract boolean isChanged(); +} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioTypeViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioTypeViewController.java deleted file mode 100644 index e1f32c787b72d6159d8d2ee15772f15db5d4bdcb..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/AudioTypeViewController.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.tobias.playpad.viewcontroller; - -import java.util.ResourceBundle; - -import de.tobias.utils.ui.ContentViewController; - - -public abstract class AudioTypeViewController extends ContentViewController { - - public AudioTypeViewController(String name, String path, ResourceBundle localization) { - super(name, path, localization); - } - - public abstract boolean isChanged(); -} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartDesignViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartDesignViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..551ca726269db154a5fee879450aeef4e0f53e05 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartDesignViewController.java @@ -0,0 +1,13 @@ +package de.tobias.playpad.viewcontroller; + +import java.util.ResourceBundle; + +import de.tobias.playpad.design.CartDesign; +import de.tobias.utils.ui.ContentViewController; + +public abstract class CartDesignViewController extends ContentViewController { + + public CartDesignViewController(String name, String path, ResourceBundle localization, CartDesign layout) { + super(name, path, localization); + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartLayoutViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartLayoutViewController.java deleted file mode 100644 index d1de69a313c2bd3ea9f2d8d591b8f90b98b0c75c..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartLayoutViewController.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.tobias.playpad.viewcontroller; - -import java.util.ResourceBundle; - -import de.tobias.playpad.layout.CartLayout; -import de.tobias.utils.ui.ContentViewController; - -public abstract class CartLayoutViewController extends ContentViewController { - - public CartLayoutViewController(String name, String path, ResourceBundle localization, CartLayout layout) { - super(name, path, localization); - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalDesignViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalDesignViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..4681c63e6c471d3ffd8c17c59dd45891a0cac72d --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalDesignViewController.java @@ -0,0 +1,13 @@ +package de.tobias.playpad.viewcontroller; + +import java.util.ResourceBundle; + +import de.tobias.playpad.design.GlobalDesign; +import de.tobias.utils.ui.ContentViewController; + +public abstract class GlobalDesignViewController extends ContentViewController { + + public GlobalDesignViewController(String name, String path, ResourceBundle localization, GlobalDesign layout) { + super(name, path, localization); + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalLayoutViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalLayoutViewController.java deleted file mode 100644 index 0e7c41f4966360c5ba2db7a43e45d013bbcdf36d..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalLayoutViewController.java +++ /dev/null @@ -1,13 +0,0 @@ -package de.tobias.playpad.viewcontroller; - -import java.util.ResourceBundle; - -import de.tobias.playpad.layout.GlobalLayout; -import de.tobias.utils.ui.ContentViewController; - -public abstract class GlobalLayoutViewController extends ContentViewController { - - public GlobalLayoutViewController(String name, String path, ResourceBundle localization, GlobalLayout layout) { - super(name, path, localization); - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/IMappingTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/IMappingTabViewController.java index baa8dc1c372ef7510e8cfe506ad82a817df518d7..7c28555f6eb9d68d2b64d94e0c3373589309959f 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/IMappingTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/IMappingTabViewController.java @@ -2,7 +2,20 @@ package de.tobias.playpad.viewcontroller; import de.tobias.playpad.action.Action; +/** + * Schnittstelle für den Mapping Tab ViewController. Der Controller hat zwei Bereiche: ActionType (Optional), Action + * + * @author tobias + * + * @since 5.0.0 + */ public interface IMappingTabViewController { + /** + * Zeigt im Action Teil der View die Einstellungen zu einer Action an. + * + * @param action + * Action + */ public void showMapperFor(Action action); } 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 c5d3b78cae62ea71f1bffbf888768e6ca362342d..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/IPadView.java +++ /dev/null @@ -1,43 +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; - -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/ISettingsViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/ISettingsViewController.java deleted file mode 100644 index 173055b25647b514d39da9f6005ea04a3959a80b..0000000000000000000000000000000000000000 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/ISettingsViewController.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.tobias.playpad.viewcontroller; - -/** - * Schnittstelle um die ProfileSettingsView zu ändern. - * - * @author tobias - * - * @since 5.0.0 - */ -public interface ISettingsViewController { - - /** - * Fügt en Tab hinzu. - * - * @param videoSettingsTabViewController - * tab - */ - public void addTab(SettingsTabViewController videoSettingsTabViewController); - -} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java index 039b2d7cd5165b11b7df8043a5252446c6f5562d..4a6bb28d49299a18a4dac4725e04e72fe68ddf06 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java @@ -1,37 +1,160 @@ package de.tobias.playpad.viewcontroller.main; -import de.tobias.playpad.project.Project; +import java.util.List; + +import de.tobias.playpad.midi.MidiListener; +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; +import de.tobias.utils.ui.NotificationHandler; +import de.tobias.utils.ui.scene.NotificationPane; +import javafx.event.EventHandler; +import javafx.event.EventType; import javafx.scene.Parent; -import javafx.scene.control.MenuItem; -import javafx.scene.control.Slider; +import javafx.scene.input.KeyEvent; import javafx.scene.paint.Color; +import javafx.stage.Screen; import javafx.stage.Stage; -public interface IMainViewController { +/** + * Schnittstelle für das Hautpfenster von PlayWall. + * + * @author tobias + * + * @since 5.1.0 + * + */ +public interface IMainViewController extends NotificationHandler { + /** + * Setzt die Grid Farbe. + * + * @param color + * Neue Farbe + */ public void setGridColor(Color color); + /** + * Gibt die Stage des ViewControllers zurück. + * + * @return Stage + */ public Stage getStage(); - public void addMenuItem(MenuItem item); - - public int getPage(); - + /** + * Gibt den Root Node der View zurück. + * + * @return root node + */ public Parent getParent(); - public Project getProject(); + /** + * Registriert ein KeyEvent Listener für das Fenster. + * + * @param eventType + * Event Type + * @param listener + * Listener für Event + */ + public void registerKeyboardListener(EventType<KeyEvent> eventType, EventHandler<KeyEvent> listener); - public Slider getVolumeSlider(); + /** + * Aktualisiert den Title des Fenster. + */ + public void updateWindowTitle(); - public IMainToolbarViewController getToolbarController(); + /** + * Gibt den aktiven MenuToolbarController des Hauptfensters zurück. Dieser basiert auf dem aktuellen MainLayout. + * + * @return Controller + */ + public MenuToolbarViewController getMenuToolbarController(); + /** + * Gibt den Bildschirm zurück, wo das Fenster aktiv ist, + * + * @return Screen + */ + public Screen getScreen(); + + /** + * Erstellt die Pad Views. + */ public void createPadViews(); - public void showPage(int page); + /** + * Gibt die Nummer Aktuelle Seite zurück. (0, n) + * + * @return Nummer der Seite + */ + public int getPage(); + + /** + * Zeigt eine Seite. Sollte die Seite bereits offen sien, passiert nichts. + * + * @param page + * Page Number + * @return <code>false</code> Seite gibt es nicht. + */ + public boolean showPage(int page); + /** + * Lädt die CSS Files neu. + */ public void loadUserCss(); - public void applyColorsToMappers(); - - public void showLiveInfo(); + /** + * Gibt die PadViews zurück. + * + * @return Liste der PadViews + */ + List<IPadView> getPadViews(); + + /** + * Gibt den MIDI Handler des Hauptfensters für die Kacheln zurück. + * + * @return MIDI Handler + */ + public MidiListener getMidiHandler(); + + /** + * Setzt das Globale Volume bei den Kacheln des aktuellen Projekts. + * + * @param doubleValue + * [0..1] + */ + public void setGlobalVolume(double doubleValue); + + /** + * Setzt das MainLayout des Hauptfensters. + * + * @param mainLayoutConnect + * Neues Layout + */ + public void setMainLayout(MainLayoutConnect mainLayoutConnect); + + /** + * Führt eine Aktion für das Hauptfenster aus. Beispielsweise MenuItem in MenuToolbarController hinzufügen. Zudem wird diese Aktion + * gespeichert und bei einem Layoutwechsel erneut ausgeführt. + * + * @param runnable + * Funktion + */ + public void performLayoutDependendAction(MainLayoutHandler runnable); + + /** + * Lädt die Tastenkombinationen für das Menü und co neu. + * + * @param keys + * Einstellungen der Key Bindings + */ + public void loadKeybinding(KeyCollection keys); + + /** + * Gibt das NotificationPane zurück. + * + * @return NotificationPane + */ + public NotificationPane getNotificationPane(); } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..d6606a8ae9bca7dc1b29260b908c0b9493066cb7 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/MenuToolbarViewController.java @@ -0,0 +1,168 @@ +package de.tobias.playpad.viewcontroller.main; + +import java.util.ResourceBundle; + +import de.tobias.playpad.project.Project; +import de.tobias.playpad.settings.ProfileSettings; +import de.tobias.playpad.settings.keys.KeyCollection; +import de.tobias.playpad.view.main.MenuType; +import de.tobias.utils.ui.ContentViewController; +import javafx.scene.Node; +import javafx.scene.control.MenuItem; +import javafx.scene.control.Slider; + +/** + * Abstrakter ViewController für das Menu und die Toolbar des Hauptfenster. Jede Implementierung kann die GUI selbst bestimmen. + * + * @author tobias + * + * @since 5.1.0 + */ +public abstract class MenuToolbarViewController extends ContentViewController { + + protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; + + /** + * Erstellt einen neuen ViewController ohne Localization + * + * @param path + * Name der FXML + * @param root + * Path zur FXML + */ + public MenuToolbarViewController(String path, String root) { + super(path, root); + } + + /** + * Erstellt einen eneun ViewController. + * + * @param name + * Name der XML + * @param path + * Path zur FXML + * @param localization + * Localization ResourceBundle + */ + public MenuToolbarViewController(String name, String path, ResourceBundle localization) { + super(name, path, localization); + } + + /** + * Wird von MainViwController aufgerufen, wenn die Buttons für die einzelnen Seiten neu erstellt werden müssen. Das ist der Fall beim + * laden eines Projektes und bei Änderungen an den Einstellungen. + */ + public abstract void initPageButtons(); + + /* + * Handling Actions from MainViewController + */ + + /** + * Mit dieser Methode werden mögliche Eingaben vom Nutzer geblocked (Beispiel: GUI Element disable). Diese Methode wird bei Änderung der + * Einstellung aufgerufen. + * + * @param looked + * true locked, false unlocked + * + * @see ProfileSettings#isLocked() + */ + public abstract void setLocked(boolean looked); + + /** + * Setzt das Menü für die Einstellung Always On Top. + * + * @param alwaysOnTopActive + * <code>true</code> Menu Aktiv + */ + public abstract void setAlwaysOnTopActive(boolean alwaysOnTopActive); + + /** + * Setzt das Menü für die Einstellung FullScreen. + * + * @param fullScreenActive + * <code>true</code> FullScreen + */ + public abstract void setFullScreenActive(boolean fullScreenActive); + + // Icons + /** + * Fügt ein Node zur Toolbar hinzu. + * + * @param node + * node + */ + public abstract void addToolbarItem(Node node); + + /** + * Entfernt das Toolbar Item. + * + * @param node + * node + * @see MenuToolbarViewController#addToolbarItem(Node) + */ + public abstract void removeToolbarItem(Node node); + + // Menu Item + /** + * Fügt ein MenuItem zu einem speziellen Menu hinzu. + * + * @param item + * MenuItem + * @param type + * Position + */ + public abstract void addMenuItem(MenuItem item, MenuType type); + + /** + * Entfernt ein spezielles MenuItem vom entsprechenden Menu. + * + * @param item + * MenuItem + */ + public abstract void removeMenuItem(MenuItem item); + + /* + * Getter + */ + + /** + * Deinitialisiert den Controller. + */ + public abstract void deinit(); + + /** + * Gibt den Global Volume Slider zurück. Jede Toolbar muss einen solchen für das Global Layout enthalten. + * + * @return Slider + */ + public abstract Slider getVolumeSlider(); + + // Utils + + /** + * Hebt dem Page Button der Aktiv ist hervor. Gleichzeitig wird der vorherige Button nicht mehr Hervorgehebt. + * + * @param page + * Neue Seite + * + * @see IMainViewController#showPage(int) + */ + public abstract void highlightPageButton(int page); + + /** + * Lädt das Keyboard Binding. + * + * @param keys + * Einstellungen der Keybinding + */ + public abstract void loadKeybinding(KeyCollection keys); + + /** + * Setzt eine Refernce des aktuellen Projectes auf den ViewController. + * + * @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 new file mode 100644 index 0000000000000000000000000000000000000000..daff746be12628d5f8bafcbd01cd254dd914acdf --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java @@ -0,0 +1,66 @@ +package de.tobias.playpad.viewcontroller.option; + +import java.util.ResourceBundle; + +import de.tobias.playpad.project.Project; +import de.tobias.playpad.settings.GlobalSettings; +import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.utils.ui.ContentViewController; + +public abstract class GlobalSettingsTabViewController extends ContentViewController { + + /** + * Erstellt einen neuen Tab. + * + * @param name + * Name der FXML + * @param path + * Pfad zu FXML (ohne Dateiname) + * @param localization + * ResourceBundle oder null + */ + public GlobalSettingsTabViewController(String name, String path, ResourceBundle localization) { + super(name, path, localization); + } + + /** + * Lädt alle Einstellungen vom Model in die GUI. + * + * @param settings + * Aktuelles GlobalSettings + */ + public abstract void loadSettings(GlobalSettings settings); + + /** + * Speichert alle Änderungen in das Model. + * + * @param settings + * Aktuelles GlobalSettings + */ + 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. + * + * @return <code>true</code> Benötigt Reload + */ + public abstract boolean needReload(); + + /** + * 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. + */ + public abstract boolean validSettings(); + + /** + * Gibt den Namen für den Tab zurück. + * + * @return Display Name des Tabs. + */ + public abstract String name(); + +} 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/IGlobalSettingsViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IGlobalSettingsViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..3f1c8bf5ed47431bb2bd65581fc35cb6b7ba9f3d --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IGlobalSettingsViewController.java @@ -0,0 +1,20 @@ +package de.tobias.playpad.viewcontroller.option; + +/** + * Schnittstelle um die GlobalSettingsView zu ändern. + * + * @author tobias + * + * @since 5.1.0 + */ +public interface IGlobalSettingsViewController { + + /** + * Fügt en Tab hinzu. + * + * @param globalSettingsTabViewController + * tab + */ + public void addTab(GlobalSettingsTabViewController globalSettingsTabViewController); + +} 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/IProfileSettingsViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProfileSettingsViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..e77faa89a691432b68815149d7a7fa1ee3639099 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProfileSettingsViewController.java @@ -0,0 +1,20 @@ +package de.tobias.playpad.viewcontroller.option; + +/** + * Schnittstelle um die ProfileSettingsView zu ändern. + * + * @author tobias + * + * @since 5.0.0 + */ +public interface IProfileSettingsViewController { + + /** + * Fügt en Tab hinzu. + * + * @param profileSettingsTabViewController + * tab + */ + public void addTab(ProfileSettingsTabViewController profileSettingsTabViewController); + +} 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/IProjectSettingsViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProjectSettingsViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..5ba59e58245992fd9986d05f756915fbaec84388 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/IProjectSettingsViewController.java @@ -0,0 +1,20 @@ +package de.tobias.playpad.viewcontroller.option; + +/** + * Schnittstelle um die GlobalSettingsView zu ändern. + * + * @author tobias + * + * @since 5.1.0 + */ +public interface IProjectSettingsViewController { + + /** + * Fügt en Tab hinzu. + * + * @param projectSettingsTabViewController + * tab + */ + public void addTab(ProjectSettingsTabViewController projectSettingsTabViewController); + +} diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/SettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java similarity index 65% rename from PlayWallCore/src/de/tobias/playpad/viewcontroller/SettingsTabViewController.java rename to PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java index fba59413967875b1b17a348a546158b8016ceda5..36ac6c870f9e2bdfcefbeb0421d2aba9141570a6 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/SettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.viewcontroller; +package de.tobias.playpad.viewcontroller.option; import java.util.ResourceBundle; @@ -15,7 +15,7 @@ import de.tobias.utils.ui.ContentViewController; * @since 5.0.0 * */ -public abstract class SettingsTabViewController extends ContentViewController { +public abstract class ProfileSettingsTabViewController extends ContentViewController { /** * Erstellt einen neuen Tab. @@ -27,7 +27,7 @@ public abstract class SettingsTabViewController extends ContentViewController { * @param localization * ResourceBundle oder null */ - public SettingsTabViewController(String name, String path, ResourceBundle localization) { + public ProfileSettingsTabViewController(String name, String path, ResourceBundle localization) { super(name, path, localization); } @@ -48,27 +48,16 @@ public abstract class SettingsTabViewController extends ContentViewController { 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. */ @@ -77,7 +66,7 @@ public abstract class SettingsTabViewController extends ContentViewController { /** * Gibt den Namen für den Tab zurück. * - * @return + * @return Display Name des Tabs. */ public abstract String name(); } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java new file mode 100644 index 0000000000000000000000000000000000000000..0f4b33e9383b26ce94cae26baf12f54670534fe2 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java @@ -0,0 +1,75 @@ +package de.tobias.playpad.viewcontroller.option; + +import java.util.ResourceBundle; + +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.utils.ui.ContentViewController; + +/** + * Abstracter Tab für Project Einstellungen. + * + * @author tobias + * + * @since 5.1.0 + * + * @see IProjectSettingsViewController + */ +public abstract class ProjectSettingsTabViewController extends ContentViewController { + + /** + * Erstellt einen neuen Tab. + * + * @param name + * Name der FXML + * @param path + * Pfad zu FXML (ohne Dateiname) + * @param localization + * ResourceBundle oder null + */ + public ProjectSettingsTabViewController(String name, String path, ResourceBundle localization) { + super(name, path, localization); + } + + /** + * Lädt alle Einstellungen vom Model in die GUI. + * + * @param settings + * Aktuelles Project Einstellungen + */ + public abstract void loadSettings(ProjectSettings settings); + + /** + * Speichert alle Änderungen in das Model. + * + * @param settings + * Aktuelles Project Einstellungen + */ + 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. + * + * @return <code>true</code> Benötigt Reload + */ + public abstract boolean needReload(); + + /** + * 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. + */ + public abstract boolean validSettings(); + + /** + * Gibt den Namen für den Tab zurück. + * + * @return Display Name des Tabs. + */ + public abstract String name(); + +} diff --git a/PlayWallCore/src/de/tobias/playpad/xml/XMLDeserializer.java b/PlayWallCore/src/de/tobias/playpad/xml/XMLDeserializer.java index b458b2bbbbbe92ee5f73321857d5574db09fb816..44581a3fffa50762840ba748a4a6206a103cc67b 100644 --- a/PlayWallCore/src/de/tobias/playpad/xml/XMLDeserializer.java +++ b/PlayWallCore/src/de/tobias/playpad/xml/XMLDeserializer.java @@ -16,7 +16,8 @@ public interface XMLDeserializer<T> { * Lädt ein Object auf XML Daten. * * @param element - * @return + * XML Objekt + * @return Daten aus dem XML */ public T loadElement(Element element); diff --git a/PlayWallCore/src/de/tobias/playpad/xml/XMLHandler.java b/PlayWallCore/src/de/tobias/playpad/xml/XMLHandler.java index 0ba39178b14a48772acb9a7abde893467bd36055..b106b92fc33910801ec9e8346818b42eb24fcaba 100644 --- a/PlayWallCore/src/de/tobias/playpad/xml/XMLHandler.java +++ b/PlayWallCore/src/de/tobias/playpad/xml/XMLHandler.java @@ -72,7 +72,9 @@ public class XMLHandler<T> { if (object instanceof Element) { Element element = (Element) object; T data = deserializer.loadElement(element); - list.add(data); + if (data != null) { + list.add(data); + } } } @@ -117,4 +119,13 @@ public class XMLHandler<T> { throw new FileNotFoundException(path.toString()); } } + + /** + * Gibt das RootElement zurück. + * + * @return Root Element + */ + public Element getRootElement() { + return rootElement; + } } diff --git a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/assets/Actions.xml b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/assets/Actions.xml new file mode 100644 index 0000000000000000000000000000000000000000..b8727f3b34c0165a078e4010a5181878e91f8213 --- /dev/null +++ b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/assets/Actions.xml @@ -0,0 +1,4 @@ +<Actions> + <Component id="MUTE">de.tobias.playpad.actionsplugin.muteaction.MuteActionConnect</Component> + <Component id="STOP">de.tobias.playpad.actionsplugin.stopaction.StopActionConnect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java index e2eada8fc11a706ef0200fd4f5224cf366bca4fd..e698c26478e0e502356409b33536c839ee0a7948 100644 --- a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java +++ b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java @@ -1,14 +1,16 @@ package de.tobias.playpad.actionsplugin.impl; +import java.io.IOException; import java.util.MissingResourceException; import java.util.ResourceBundle; +import org.dom4j.DocumentException; + import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.action.ActionRegistery; +import de.tobias.playpad.action.ActionConnect; import de.tobias.playpad.actionsplugin.ActionsPlugin; -import de.tobias.playpad.actionsplugin.muteaction.MuteActionConnect; -import de.tobias.playpad.actionsplugin.stopaction.StopActionConnect; import de.tobias.playpad.plugin.WindowListener; +import de.tobias.playpad.registry.Registry; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileListener; import de.tobias.playpad.update.UpdateRegistery; @@ -63,20 +65,24 @@ public class ActionsPluginImpl implements ActionsPlugin, ChangeListener<Boolean> muteHUD.setMinHeight(100); }); + ChangeListener<Boolean> listener = (a, b, c) -> + { + if (c && volume == -1 && Profile.currentProfile().getProfileSettings().getVolume() != 0) { + volume = Profile.currentProfile().getProfileSettings().getVolume(); + } else { + volume = -1; + } + }; + PlayPadPlugin.getImplementation().addMainViewListener(new WindowListener<IMainViewController>() { @Override public void onInit(IMainViewController t) { - t.getVolumeSlider().valueChangingProperty().addListener(new ChangeListener<Boolean>() { - - @Override - public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { - if (newValue && volume == -1 && Profile.currentProfile().getProfileSettings().getVolume() != 0) { - volume = Profile.currentProfile().getProfileSettings().getVolume(); - } else { - volume = -1; - } - } + t.performLayoutDependendAction((oldToolbar, newToolbar) -> + { + if (oldToolbar != null) + oldToolbar.getVolumeSlider().valueChangingProperty().removeListener(listener); + newToolbar.getVolumeSlider().valueChangingProperty().addListener(listener); }); } }); @@ -97,9 +103,12 @@ public class ActionsPluginImpl implements ActionsPlugin, ChangeListener<Boolean> UpdateRegistery.registerUpdateable(new ActionsPluginUpdater()); Profile.registerListener(this); - ActionRegistery.registerActionConnect(new MuteActionConnect()); - ActionRegistery.registerActionConnect(new StopActionConnect()); - + try { + Registry<ActionConnect> padContents = PlayPadPlugin.getRegistryCollection().getActions(); + padContents.loadComponentsFromFile("de/tobias/playpad/actionsplugin/assets/Actions.xml", getClass().getClassLoader()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | DocumentException e) { + e.printStackTrace(); + } muteProperty.addListener(this); System.out.println("Enable Action Plugin"); diff --git a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java index 42b536e0ec16ed773b68a36db6a505652ed05dab..ead13c66e180a23982c29bc06f9354e0d6fd2059 100644 --- a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java +++ b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java @@ -16,18 +16,19 @@ import de.tobias.playpad.plugin.SettingsListener; import de.tobias.playpad.plugin.WindowListener; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.update.UpdateRegistery; -import de.tobias.playpad.viewcontroller.main.IMainToolbarViewController; +import de.tobias.playpad.view.main.MenuType; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; 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; @@ -146,8 +147,23 @@ public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewCon activeMenu.setOnAction(this); activeMenu.setText(bundle.getString("menutitle")); activeMenu.setSelected(settings.active); - t.addMenuItem(activeMenu); + t.performLayoutDependendAction((oldToolbar, newToolbar) -> + { + if (oldToolbar != null) + oldToolbar.removeMenuItem(activeMenu); + newToolbar.addMenuItem(activeMenu, MenuType.EXTENSION); + + if (iconLabel != null) { + if (settings.active) { + if (oldToolbar != null) + oldToolbar.removeToolbarItem(iconLabel); + newToolbar.addToolbarItem(iconLabel); + } else { + newToolbar.removeToolbarItem(iconLabel); + } + } + }); iconLabel = new Label(); iconLabel.setGraphic(new FontIcon(FontAwesomeType.MOON_ALT)); } @@ -157,11 +173,11 @@ public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewCon activeSleep(activeMenu.isSelected()); settings.active = activeMenu.isSelected(); - IMainToolbarViewController toolbarController = PlayPadPlugin.getImplementation().getMainViewController().getToolbarController(); + MenuToolbarViewController toolbarController = PlayPadPlugin.getImplementation().getMainViewController().getMenuToolbarController(); if (settings.active) { - toolbarController.showIcon(iconLabel); + toolbarController.addToolbarItem(iconLabel); } else { - toolbarController.hideIcon(iconLabel); + toolbarController.removeToolbarItem(iconLabel); } } diff --git a/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java b/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java index 54282b74205cbd36efc93cc0d8b20964c81a7f1c..92c5255726809d7b30ee09b4158ccfcdaa2ce47f 100644 --- a/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java +++ b/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java @@ -14,6 +14,7 @@ import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.plugin.PadListener; import de.tobias.playpad.plugin.WindowListener; import de.tobias.playpad.update.UpdateRegistery; +import de.tobias.playpad.view.main.MenuType; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; @@ -71,7 +72,13 @@ public class EqualizerPluginImpl implements EqualizerPlugin, WindowListener<IMai eqMenuItem = new MenuItem(); eqMenuItem.setText(bundle.getString("eq.menuitem.name")); eqMenuItem.setOnAction(this); - t.addMenuItem(eqMenuItem); + + t.performLayoutDependendAction((oldToolbar, newToolbar) -> + { + if (oldToolbar != null) + oldToolbar.removeMenuItem(eqMenuItem); + newToolbar.addMenuItem(eqMenuItem, MenuType.EXTENSION); + }); } @Override diff --git a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/mk2/LaunchPadMK2Color.java b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/mk2/LaunchPadMK2Color.java index 931b455a19bd03cfa642bad8e1e8acd5b51520aa..71770ee1032927b18827caac8d0a2186f00179f4 100644 --- a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/mk2/LaunchPadMK2Color.java +++ b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/mk2/LaunchPadMK2Color.java @@ -64,7 +64,7 @@ public enum LaunchPadMK2Color implements DisplayableFeedbackColor { } @Override - public int midiVelocity() { + public int mapperFeedbackValue() { return midi; } @@ -75,7 +75,7 @@ public enum LaunchPadMK2Color implements DisplayableFeedbackColor { public static DisplayableFeedbackColor valueOf(int id) { for (LaunchPadMK2Color color : values()) { - if (color.midiVelocity() == id) { + if (color.mapperFeedbackValue() == id) { return color; } } diff --git a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/s/LaunchPadSColor.java b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/s/LaunchPadSColor.java index 1094ba3119cd89eff93603069c9e8af7a9ef2b24..d6bfb63c4e5cad44d582afc51f5cd791558d6334 100644 --- a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/s/LaunchPadSColor.java +++ b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/s/LaunchPadSColor.java @@ -20,7 +20,7 @@ public enum LaunchPadSColor implements DisplayableFeedbackColor { } @Override - public int midiVelocity() { + public int mapperFeedbackValue() { return midi; } @@ -31,7 +31,7 @@ public enum LaunchPadSColor implements DisplayableFeedbackColor { public static DisplayableFeedbackColor valueOf(int id) { for (LaunchPadSColor color : values()) { - if (color.midiVelocity() == id) { + if (color.mapperFeedbackValue() == id) { return color; } } diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/assets/Actions.xml b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/assets/Actions.xml new file mode 100644 index 0000000000000000000000000000000000000000..9686e34b9996de2bbf36b8fec42e66dfcf96a1f1 --- /dev/null +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/assets/Actions.xml @@ -0,0 +1,3 @@ +<Actions> + <Component id="BLIND">de.tobias.playpad.mediaplugin.blindaction.BlindActionConnect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/assets/PadContent.xml b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/assets/PadContent.xml new file mode 100644 index 0000000000000000000000000000000000000000..5be46a07f09a288d2a5440e2100dc7fef4079824 --- /dev/null +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/assets/PadContent.xml @@ -0,0 +1,4 @@ +<Actions> + <Component id="video">de.tobias.playpad.mediaplugin.video.VideoContentConntect</Component> + <Component id="image">de.tobias.playpad.mediaplugin.image.ImageContentConntect</Component> +</Actions> \ No newline at end of file diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/plugin/image/ImageContent.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java similarity index 92% rename from PlayWallPlugins/mediaplugin/de/tobias/playpad/plugin/image/ImageContent.java rename to PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java index 92e4eb5c994c95a5e936d20664f31a555493663d..9c310081e55225e2ea8fd37d05ddd2526ef9c891 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/plugin/image/ImageContent.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java @@ -1,6 +1,7 @@ -package de.tobias.playpad.plugin.image; +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/plugin/image/ImageContentConntect.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContentConntect.java similarity index 98% rename from PlayWallPlugins/mediaplugin/de/tobias/playpad/plugin/image/ImageContentConntect.java rename to PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContentConntect.java index d3d80d8ecebf6d58d2eacb7181238fadb7b92e70..53e049cd4799802c5ab74d5d44d6c3ab5cedf81d 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/plugin/image/ImageContentConntect.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContentConntect.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.plugin.image; +package de.tobias.playpad.mediaplugin.image; import de.tobias.playpad.mediaplugin.main.impl.MediaPluginImpl; import de.tobias.playpad.mediaplugin.main.impl.Strings; diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaPluginImpl.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaPluginImpl.java index a430a722c38d923f74bfb3e38897e50dfa402a8d..7b71b3255ffa67ac72acbcee2bd858ecb636e47e 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaPluginImpl.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaPluginImpl.java @@ -8,14 +8,12 @@ import java.util.ResourceBundle; import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.action.ActionRegistery; -import de.tobias.playpad.mediaplugin.blindaction.BlindActionConnect; +import de.tobias.playpad.action.ActionConnect; import de.tobias.playpad.mediaplugin.main.VideoPlugin; import de.tobias.playpad.mediaplugin.main.VideoSettings; -import de.tobias.playpad.mediaplugin.video.VideoContentConntect; -import de.tobias.playpad.pad.conntent.PadContentRegistry; +import de.tobias.playpad.pad.conntent.PadContentConnect; import de.tobias.playpad.plugin.SettingsListener; -import de.tobias.playpad.plugin.image.ImageContentConntect; +import de.tobias.playpad.registry.Registry; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.update.UpdateRegistery; import de.tobias.utils.ui.HUD; @@ -55,8 +53,13 @@ public class MediaPluginImpl implements VideoPlugin, SettingsListener, ChangeLis bundle = Localization.loadBundle("de/tobias/playpad/mediaplugin/assets/video", getClass().getClassLoader()); videoViewController = new MediaViewController(settings); - PadContentRegistry.registerActionConnect(new VideoContentConntect()); - PadContentRegistry.registerActionConnect(new ImageContentConntect()); + // Load Content Types + try { + Registry<PadContentConnect> padContents = PlayPadPlugin.getRegistryCollection().getPadContents(); + padContents.loadComponentsFromFile("de/tobias/playpad/mediaplugin/assets/PadContent.xml", getClass().getClassLoader()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | DocumentException e) { + e.printStackTrace(); + } PlayPadPlugin.getImplementation().addSettingsListener(this); @@ -81,8 +84,13 @@ public class MediaPluginImpl implements VideoPlugin, SettingsListener, ChangeLis } UpdateRegistery.registerUpdateable(new MediaPluginUpdater()); - ActionRegistery.registerActionConnect(new BlindActionConnect()); + try { + Registry<ActionConnect> padContents = PlayPadPlugin.getRegistryCollection().getActions(); + padContents.loadComponentsFromFile("de/tobias/playpad/mediaplugin/assets/Actions.xml", getClass().getClassLoader()); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | DocumentException e) { + e.printStackTrace(); + } blindProperty.addListener(this); System.out.println("Enable Media Plugin"); 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 0ebe6c7e678a04fa952aba4b8a5eb60bff3ce694..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.viewcontroller.SettingsTabViewController; +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 SettingsTabViewController { +public class MediaSettingsTabViewController extends ProfileSettingsTabViewController implements IProfileReloadTask { @FXML private Pane screenViewPane; @FXML private ComboBox<Integer> screenComboBox; @@ -118,13 +121,22 @@ public class MediaSettingsTabViewController extends SettingsTabViewController { } @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/main/impl/MediaViewController.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaViewController.java index 307b2e60c947dc85fbdbe6bad4f03c8dc7816428..9c7a8b14a5af3d8246d9a8996658149441780fd6 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaViewController.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaViewController.java @@ -5,11 +5,11 @@ import java.nio.file.Files; import java.nio.file.Path; import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.mediaplugin.image.ImageContent; import de.tobias.playpad.mediaplugin.main.VideoSettings; import de.tobias.playpad.mediaplugin.video.VideoContent; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.plugin.image.ImageContent; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileListener; import de.tobias.utils.application.ApplicationUtils; diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java index 021b6458fab9660f5c01773afb0dc049631c7eb5..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; @@ -8,10 +9,11 @@ import org.dom4j.Element; import de.tobias.playpad.mediaplugin.main.impl.MediaPluginImpl; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.pad.conntent.Durationable; import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.pad.conntent.Pauseable; +import de.tobias.playpad.pad.conntent.play.Durationable; +import de.tobias.playpad.pad.conntent.play.Pauseable; import de.tobias.playpad.project.ProjectExporter; import de.tobias.playpad.settings.Profile; import de.tobias.utils.util.ZipFile; @@ -50,7 +52,8 @@ public class VideoContent extends PadContent implements Pauseable, Durationable }; customVolumeListener = (a, b, c) -> { - player.setVolume(getPad().getVolume() * Profile.currentProfile().getProfileSettings().getVolume() * c.doubleValue()); + player.setVolume( + getPad().getPadSettings().getVolume() * Profile.currentProfile().getProfileSettings().getVolume() * c.doubleValue()); }; } @@ -68,16 +71,16 @@ 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(); } @Override public void setMasterVolume(double masterVolume) { if (player != null) { - player.setVolume(getPad().getVolume() * masterVolume * getPad().getCustomVolume()); + player.setVolume(getPad().getPadSettings().getVolume() * masterVolume * getPad().getCustomVolume()); } } @@ -107,8 +110,10 @@ public class VideoContent extends PadContent implements Pauseable, Durationable @Override public boolean stop() { - if (getPad().getCustomSettings().containsKey(VIDEO_LAST_FRAME) && !holdLastFrame && getPad().isEof()) { - if ((boolean) getPad().getCustomSettings().get(VIDEO_LAST_FRAME)) { + PadSettings padSettings = getPad().getPadSettings(); + + if (padSettings.getCustomSettings().containsKey(VIDEO_LAST_FRAME) && !holdLastFrame && getPad().isEof()) { + if ((boolean) padSettings.getCustomSettings().get(VIDEO_LAST_FRAME)) { getPad().setStatus(PadStatus.PAUSE); holdLastFrame = true; return false; @@ -154,7 +159,7 @@ public class VideoContent extends PadContent implements Pauseable, Durationable Platform.runLater(() -> { if (getPad().isPadVisible()) { - getPad().getController().getParent().setBusy(true); + getPad().getController().getView().showBusyView(true); } }); media = new Media(path.toUri().toString()); @@ -174,7 +179,7 @@ public class VideoContent extends PadContent implements Pauseable, Durationable Platform.runLater(() -> { if (getPad().isPadVisible()) { - getPad().getController().getParent().setBusy(false); + getPad().getController().getView().showBusyView(false); } }); }); @@ -184,14 +189,14 @@ public class VideoContent extends PadContent implements Pauseable, Durationable Platform.runLater(() -> { if (getPad().isPadVisible()) { - getPad().getController().getParent().setBusy(false); + getPad().getController().getView().showBusyView(false); } }); getPad().throwException(path, player.getError()); }); player.setOnEndOfMedia(() -> { - if (!getPad().isLoop()) { + if (!getPad().getPadSettings().isLoop()) { getPad().setEof(true); getPad().setStatus(PadStatus.STOP); } else { @@ -203,7 +208,7 @@ public class VideoContent extends PadContent implements Pauseable, Durationable durationProperty.bind(player.totalDurationProperty()); positionProperty.bind(player.currentTimeProperty()); - getPad().volumeProperty().addListener(padVolumeListener); + getPad().getPadSettings().volumeProperty().addListener(padVolumeListener); getPad().customVolumeProperty().addListener(customVolumeListener); } } @@ -213,7 +218,7 @@ public class VideoContent extends PadContent implements Pauseable, Durationable durationProperty.unbind(); positionProperty.unbind(); - getPad().volumeProperty().removeListener(padVolumeListener); + getPad().getPadSettings().volumeProperty().removeListener(padVolumeListener); getPad().customVolumeProperty().removeListener(customVolumeListener); player = null; diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContentConntect.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContentConntect.java index 65a48ac94219ed5e8bcf28e4f0d1db0da86d1f69..4fd611c04cf87898c2e1e6f476aaf90754653cdc 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContentConntect.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContentConntect.java @@ -8,7 +8,7 @@ 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.viewcontroller.PadSettingsTabViewController; -import de.tobias.playpad.viewcontroller.SettingsTabViewController; +import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import javafx.beans.property.SimpleStringProperty; @@ -49,7 +49,7 @@ public class VideoContentConntect extends PadContentConnect { } @Override - public SettingsTabViewController getSettingsTabViewController(boolean activePlayer) { + public ProfileSettingsTabViewController getSettingsTabViewController(boolean activePlayer) { MediaPluginImpl instance = MediaPluginImpl.getInstance(); return new MediaSettingsTabViewController(instance.getCurrentSettings()); } diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoPadSettingsTabViewController.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoPadSettingsTabViewController.java index b7a0f0592cc609c6b5ab25ab5697d030d431c80d..a430bbb6893280726546f50dfc50f832afe2801c 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoPadSettingsTabViewController.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoPadSettingsTabViewController.java @@ -21,13 +21,13 @@ public class VideoPadSettingsTabViewController extends PadSettingsTabViewControl @Override public void loadSettings(Pad pad) { - if (pad.getCustomSettings().containsKey(VideoContent.VIDEO_LAST_FRAME)) - lastFrameCheckBox.setSelected((boolean) pad.getCustomSettings().get(VideoContent.VIDEO_LAST_FRAME)); + if (pad.getPadSettings().getCustomSettings().containsKey(VideoContent.VIDEO_LAST_FRAME)) + lastFrameCheckBox.setSelected((boolean) pad.getPadSettings().getCustomSettings().get(VideoContent.VIDEO_LAST_FRAME)); } @Override public void saveSettings(Pad pad) { - pad.getCustomSettings().put(VideoContent.VIDEO_LAST_FRAME, lastFrameCheckBox.isSelected()); + pad.getPadSettings().getCustomSettings().put(VideoContent.VIDEO_LAST_FRAME, lastFrameCheckBox.isSelected()); } }