diff --git a/PlayWall/assets/de/tobias/playpad/assets/files/class_obj.png b/PlayWall/assets/de/tobias/playpad/assets/files/class_obj.png new file mode 100644 index 0000000000000000000000000000000000000000..bc915da4420060b4ea9984fc662935f10f19449a Binary files /dev/null and b/PlayWall/assets/de/tobias/playpad/assets/files/class_obj.png differ diff --git a/PlayWall/assets/de/tobias/playpad/assets/files/enum_obj.png b/PlayWall/assets/de/tobias/playpad/assets/files/enum_obj.png new file mode 100644 index 0000000000000000000000000000000000000000..c2b5d8345058a26e8ffb4262277543bce417535b Binary files /dev/null and b/PlayWall/assets/de/tobias/playpad/assets/files/enum_obj.png differ diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties index b7948216b5f8aae5e7d3e16d31c0d683347ecb1d..9eb27f1ec8539aa03b41a1afd05c1c417de97d21 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties @@ -93,7 +93,7 @@ UI.Dialog.Profile.Delete.Content=Sind Sie sicher, dass Sie das Profil {} l # UI - Dialog - Info UI.Dialog.Info.Header=�ber {} -UI.Dialog.Info.Content=Version: {} (Build: {})\nAutor: {}\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.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. @@ -205,13 +205,16 @@ CartAction.Mode.PLAY_HOLD=Play/Hold 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.) +# Update Channel - BaseName +UpdateChannel.STABLE=Stabil +UpdateChannel.BETA=Beta + # Error - Layout Error.Layout.Load=Es gab einen Fehler beim Laden des Layouts ({}) # UI - Dialog - Update UI.Dialog.Update.Cell={}: Installiert: {} - Neu: {} UI.Window.Settings.Updates.CurrentVersion={} (Build {}) -UI.Window.Settings.Updates.NewVersion={} (Build {}) # Error - Update - Downlaod Error.Update.Download=Es ist ein Fehler beim Herunterladen des Updates aufgetreten. Bitte versuchen Sie es sp�ter erneut. ({}) 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 96235bf6de5b7347a56ecff96b82d100a3fa9efa..1ad02a367c7a457e081958a4693bd4964f761953 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties @@ -69,6 +69,9 @@ 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.infoE=Erweiterung settings.button.finish=Fertig settings.checkbox.activate=Aktivieren diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml index 91c68b8a000fcfe5f6028a2d03f1ab06a68131cf..2f2c940576518b11583a9901fd0554f67d96ad10 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/updateTab.fxml @@ -5,7 +5,6 @@ <?import java.lang.*?> <?import javafx.scene.layout.*?> - <VBox spacing="14.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <children> <HBox layoutX="14.0" layoutY="14.0" spacing="14.0"> @@ -14,12 +13,6 @@ <Label fx:id="currentVersionLabel" layoutX="175.0" layoutY="14.0" text="5.0.1 (stable)" /> </children> </HBox> - <HBox layoutX="14.0" layoutY="36.0" spacing="14.0"> - <children> - <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="36.0" prefWidth="150.0" text="%settings.update.label.new" /> - <Label fx:id="newVersionLabel" layoutX="175.0" layoutY="36.0" text="5.0.2 (stable)" /> - </children> - </HBox> <Separator prefWidth="200.0" /> <HBox spacing="14.0"> <children> @@ -27,6 +20,12 @@ <CheckBox fx:id="automaticSearchCheckBox" layoutX="275.0" layoutY="183.0" mnemonicParsing="false" text="Automatisch" /> </children> </HBox> + <HBox alignment="CENTER_LEFT" spacing="14.0"> + <children> + <Label alignment="CENTER_RIGHT" prefWidth="150.0" text="%settings.update.label.channel" /> + <ComboBox fx:id="updateChannelComboBox" prefWidth="150.0" /> + </children> + </HBox> <HBox spacing="14.0"> <children> <Label alignment="CENTER_RIGHT" layoutX="106.0" layoutY="222.0" prefWidth="150.0" /> @@ -37,7 +36,17 @@ <HBox spacing="14.0"> <children> <Label alignment="CENTER_RIGHT" prefWidth="150.0" text="%settings.update.label.available" /> - <ListView fx:id="openUpdateList" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" /> + <VBox spacing="14.0" HBox.hgrow="ALWAYS"> + <children> + <ListView fx:id="openUpdateList" prefHeight="200.0" prefWidth="200.0" HBox.hgrow="ALWAYS" /> + <HBox spacing="14.0"> + <children> + <Label fx:id="infoCLabel" text="%settings.update.label.infoC" /> + <Label fx:id="infoELabel" text="%settings.update.label.infoE" /> + </children> + </HBox> + </children> + </VBox> </children> </HBox> <HBox alignment="TOP_RIGHT"> diff --git a/PlayWall/beta.xml b/PlayWall/beta.xml new file mode 100644 index 0000000000000000000000000000000000000000..868e16cb0249dfca19c4e9500162f3f3539b59df --- /dev/null +++ b/PlayWall/beta.xml @@ -0,0 +1,53 @@ +<project name="Build App" default="buildApp" basedir="/Users/tobias/Documents/Programmieren/Java/eclipse/"> + + <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="/Users/tobias/Documents/Programmieren/Java/ant/lib/appbundler-1.0.jar" /> + <taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="/Users/tobias/Documents/Programmieren/Java/ant/lib/launch4j/launch4j.jar:${launch4j.dir}/lib/xstream.jar" /> + <taskdef name="upload" classname="de.tobias.playwallpm.task.PlayWallPMTask" classpath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWallPackageManager/build/PlayWallPM.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/jsch/jsch-0.1.53.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/YAMLStorage.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/snakeyaml-1.11.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/guava-15.0.jar" /> + <taskdef name="buildNumber" classname="de.tobias.playwallpm.task.BuildNumberTask" classpath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWallPackageManager/build/PlayWallPM.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/jsch/jsch-0.1.53.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/YAMLStorage.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/snakeyaml-1.11.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/guava-15.0.jar" /> + + <target name="buildApp"> + + <!-- Update Version Number --> + <buildNumber path="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/src/application.yml" /> + <buildNumber path="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin/application.yml" /> + + <!-- Build Jar --> + <jar destfile="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.jar"> + <manifest> + <attribute name="Main-Class" value="de.tobias.playpad.PlayPadMain" /> + </manifest> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.class" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.png" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.yml" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.fxml" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.css" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.properties" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWallCore/bin" includes="**/*.class" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/libs/libUtils/bin" includes="**/*.class" /> + + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/JavaFX/controlsfx-8/" includes="controlsfx-8.40.10.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/XML/" includes="dom4j-1.6.1.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/" includes="guava-15.0.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/" includes="snakeyaml-1.11.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/" includes="YAMLStorage.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/HTML/" includes="gagawa-1.0.1.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/jspf/dist/" includes="jspf.core-1.0.2.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/tinysound/" includes="tinysound-1.1.1.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/tinysound/lib/" includes="**/*.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/JLayer1.0.1/" includes="jl1.0.1.jar" /> + </jar> + + <!-- Upload Jar --> + <input addproperty="password">Enter password</input> + + <upload username="p35947554-pw" password="${password}" host="p35947554.1and1-data.host" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.jar" remotePath="beta" remoteFileName="PlayWall.jar"/> + </target> +</project> \ No newline at end of file diff --git a/PlayWall/build.xml b/PlayWall/build.xml index e8324556f5f6a303a6df0b63b0678131adb3e6c2..9de34d18406787222018b81c331fef80d878d209 100644 --- a/PlayWall/build.xml +++ b/PlayWall/build.xml @@ -1,32 +1,60 @@ <project name="Build App" default="buildApp" basedir="/Users/tobias/Documents/Programmieren/Java/eclipse/"> - - <taskdef name="bundleapp" - classname="com.oracle.appbundler.AppBundlerTask" - classpath="/Users/tobias/Documents/Programmieren/Java/ant/lib/appbundler-1.0.jar" /> - - <taskdef name="launch4j" - classname="net.sf.launch4j.ant.Launch4jTask" - classpath="/Users/tobias/Documents/Programmieren/Java/ant/lib/launch4j/launch4j.jar:${launch4j.dir}/lib/xstream.jar" /> - - <target name="buildApp"> - <bundleapp outputdirectory="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/dist" - name="Play Wall" - displayname="Play Wall" - identifier="de.tobias.playwall" - mainclassname="de.tobias.playpad.PlayPadMain" - icon="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/src/icon.icns"> - <runtime dir="/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home" /> - <classpath file="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.jar" /> - </bundleapp> - - <launch4j> - <config headerType="gui" outfile="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/dist/PlayWall.exe" - dontWrapJar="false" jarPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.jar" - icon="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/src/icon.ico" > - <classPath mainClass="de.tobias.playpad.PlayPadMain" /> - <jre minVersion="1.8.0"> - </jre> - </config> - </launch4j> - </target> + + <taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask" classpath="/Users/tobias/Documents/Programmieren/Java/ant/lib/appbundler-1.0.jar" /> + <taskdef name="launch4j" classname="net.sf.launch4j.ant.Launch4jTask" classpath="/Users/tobias/Documents/Programmieren/Java/ant/lib/launch4j/launch4j.jar:${launch4j.dir}/lib/xstream.jar" /> + <taskdef name="upload" classname="de.tobias.playwallpm.task.PlayWallPMTask" classpath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWallPackageManager/build/PlayWallPM.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/jsch/jsch-0.1.53.jar" /> + <taskdef name="buildNumber" classname="de.tobias.playwallpm.task.BuildNumberTask" classpath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWallPackageManager/build/PlayWallPM.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/jsch/jsch-0.1.53.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/YAMLStorage.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/snakeyaml-1.11.jar: + /Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/guava-15.0.jar" /> + + <target name="buildApp"> + + <!-- Update Version Number --> + + <jar destfile="PlayWall/build/PlayWall.jar"> + <manifest> + <attribute name="Main-Class" value="de.tobias.playpad.PlayPadMain" /> + </manifest> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.class" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.png" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.yml" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.fxml" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.css" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/bin" includes="**/*.properties" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWallCore/bin" includes="**/*.class" /> + <fileset dir="/Users/tobias/Documents/Programmieren/Java/git/libs/libUtils/bin" includes="**/*.class" /> + + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/JavaFX/controlsfx-8/" includes="controlsfx-8.40.10.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/XML/" includes="dom4j-1.6.1.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/" includes="guava-15.0.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/" includes="snakeyaml-1.11.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/YAML/" includes="YAMLStorage.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/File Parser/HTML/" includes="gagawa-1.0.1.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/jspf/dist/" includes="jspf.core-1.0.2.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/tinysound/" includes="tinysound-1.1.1.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/tinysound/lib/" includes="**/*.jar" /> + <zipgroupfileset dir="/Users/tobias/Documents/Programmieren/Java/Libraries/JLayer1.0.1/" includes="jl1.0.1.jar" /> + </jar> + + <bundleapp outputdirectory="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/dist" name="Play Wall" displayname="Play Wall" identifier="de.tobias.playwall" mainclassname="de.tobias.playpad.PlayPadMain" icon="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/src/icon.icns"> + <runtime dir="/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home" /> + <classpath file="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.jar" /> + </bundleapp> + + <launch4j> + <config headerType="gui" outfile="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/dist/PlayWall.exe" dontWrapJar="false" jarPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.jar" icon="/Users/tobias/Documents/Programmieren/Java/git/PlayWall/PlayWall/src/icon.ico"> + <classPath mainClass="de.tobias.playpad.PlayPadMain" /> + <jre minVersion="1.8.0"> + </jre> + </config> + </launch4j> + + <input addproperty="password">Enter password</input> + + <upload username="p35947554-pw" password="${password}" host="p35947554.1and1-data.host" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.jar" remotePath="beta" remoteFileName="PlayWall.jar" /> + <upload username="p35947554-pw" password="${password}" host="p35947554.1and1-data.host" localPath="/Users/tobias/Documents/Programmieren/Java/eclipse/PlayWall/build/PlayWall.exe" remotePath="beta" remoteFileName="PlayWall.exe" /> + </target> </project> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/PlayPadMain.java b/PlayWall/src/de/tobias/playpad/PlayPadMain.java index 11d526ed177d6722671c7c405659d8a512e8cb40..a6232e848d8c1e6cbb825eef9520d4b5aa472196 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadMain.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadMain.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -53,6 +54,8 @@ 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.Updatable; +import de.tobias.playpad.update.UpdateRegistery; import de.tobias.playpad.view.MapperOverviewViewController; import de.tobias.playpad.viewcontroller.IPadSettingsViewController; import de.tobias.playpad.viewcontroller.ISettingsViewController; @@ -322,25 +325,30 @@ public class PlayPadMain extends Application implements LocalizationDelegate, Pl mainViewController = new MainViewController(project, mainViewListeners, pluginManager); } + /** + * Handle Auto Update on profile reload + */ @Override - public void reloadSettings(Profile oldProfile, Profile currentProfile) { + public void reloadSettings(Profile oldProfile, Profile newProfile) { // Update PlayWall - if (currentProfile.getProfileSettings().isAutoUpdate()) { + if (newProfile.getProfileSettings().isAutoUpdate()) { Worker.runLater(() -> { - UpdateRegistery.lookupUpdates(); - 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 { + UpdateRegistery.lookupUpdates(newProfile.getProfileSettings().getUpdateChannel()); + if (!UpdateRegistery.getAvailableUpdates().isEmpty()) { + Platform.runLater(() -> { - UpdateTabViewController.update(null); + 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 -> + { + UpdateTabViewController.update(null); + }); }); - }); - } + } + } catch (IOException | URISyntaxException e) {} }); } } diff --git a/PlayWall/src/de/tobias/playpad/PlayPadUpdater.java b/PlayWall/src/de/tobias/playpad/PlayPadUpdater.java index be3582a6293243e6558a733e46fb16159bed89a5..fa3d66a15807d4d178b1ba4f8a89d09c309ace16 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadUpdater.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadUpdater.java @@ -8,6 +8,8 @@ import java.nio.file.Path; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; +import de.tobias.playpad.update.Updatable; +import de.tobias.playpad.update.UpdateChannel; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.util.SystemUtils; @@ -30,47 +32,36 @@ public class PlayPadUpdater implements Updatable { @Override public int getNewBuild() { - if (newBuild == 0) { - checkUpdate(); - } return newBuild; } @Override public String getNewVersion() { - if (newVersion == null) { - checkUpdate(); - } return newVersion; } @Override - public boolean checkUpdate() { + public void loadInformation(UpdateChannel channel) throws IOException, URISyntaxException { App app = ApplicationUtils.getMainApplication(); - try { - URL url = new URL(app.getInfo().getUpdateURL() + "/version.yml"); - FileConfiguration config = YamlConfiguration.loadConfiguration(url.openStream()); - newBuild = config.getInt("build"); - newVersion = config.getString("version"); - - if (SystemUtils.isExe()) { - remotePath = new URL(config.getString("pathExe")); - } else { - remotePath = new URL(config.getString("pathJar")); - } - - return getCurrentBuild() < getNewBuild(); - } catch (IOException | URISyntaxException e) { - e.printStackTrace(); + URL url = new URL(app.getInfo().getUpdateURL() + "/" + channel + "/version.yml"); + FileConfiguration config = YamlConfiguration.loadConfiguration(url.openStream()); + newBuild = config.getInt("build"); + newVersion = config.getString("version"); + + if (SystemUtils.isExe() && channel == UpdateChannel.STABLE) { // EXE only for stable release + remotePath = new URL(config.getString("pathExe")); + } else { + remotePath = new URL(config.getString("pathJar")); } - return false; + } + + @Override + public boolean isUpdateAvailable() { + return getCurrentBuild() < getNewBuild(); } @Override public URL getDownloadPath() { - if (remotePath == null) { - checkUpdate(); - } return remotePath; } diff --git a/PlayWall/src/de/tobias/playpad/Strings.java b/PlayWall/src/de/tobias/playpad/Strings.java index 12c51ae815631e375741f16f0198952f759efefc..04c0cc3b3039adcf15798c37c2e9dde296f52f70 100644 --- a/PlayWall/src/de/tobias/playpad/Strings.java +++ b/PlayWall/src/de/tobias/playpad/Strings.java @@ -198,13 +198,15 @@ public class Strings { public static final String UI_Dialog_AutoUpdate_Header = "UI.Dialog.AutoUpdate.Header"; public static final String UI_Dialog_AutoUpdate_Content = "UI.Dialog.AutoUpdate.Content"; + // Update Channel - Basename + public static final String Update_Channel_BaseName = "UpdateChannel."; + // Error - Layout public static final String Error_Layout_Load = "Error.Layout.Load"; // UI - Dialog - Update public static final String UI_Dialog_Update_Cell = "UI.Dialog.Update.Cell"; public static final String UI_Window_Settings_Updates_CurrentVersion = "UI.Window.Settings.Updates.CurrentVersion"; - public static final String UI_Window_Settings_Updates_NewVersion = "UI.Window.Settings.Updates.NewVersion"; // Error - Update - Downlaod public static final String Error_Update_Download = "Error.Update.Download"; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/UpdateCell.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/UpdateCell.java index 48d27b4b90eba7e5e6e99885433f76cb0fd6494e..41830f8e77e9468b342a5172ae78f63bd5366cbd 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/UpdateCell.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/UpdateCell.java @@ -1,9 +1,11 @@ package de.tobias.playpad.viewcontroller.cell; +import de.tobias.playpad.PlayPadUpdater; import de.tobias.playpad.Strings; -import de.tobias.playpad.Updatable; +import de.tobias.playpad.update.Updatable; import de.tobias.utils.util.Localization; import javafx.scene.control.ListCell; +import javafx.scene.image.ImageView; public class UpdateCell extends ListCell<Updatable> { @@ -11,6 +13,11 @@ public class UpdateCell extends ListCell<Updatable> { protected void updateItem(Updatable item, boolean empty) { super.updateItem(item, empty); if (!empty) { + if (item instanceof PlayPadUpdater) { + setGraphic(new ImageView("de/tobias/playpad/assets/files/class_obj.png")); + } else { + setGraphic(new ImageView("de/tobias/playpad/assets/files/enum_obj.png")); + } setText(Localization.getString(Strings.UI_Dialog_Update_Cell, item.name(), item.getCurrentVersion(), item.getNewVersion())); } else { setText(""); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java index 0edd9042f39d8a1917d7f57927b18b23d6793074..a954277ec30ecee7fc62b97f6cd2cf0e81365ddb 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/UpdateTabViewController.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; @@ -15,12 +16,16 @@ import de.tobias.playpad.AppUserInfoStrings; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; -import de.tobias.playpad.Updatable; -import de.tobias.playpad.UpdateRegistery; 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.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.utils.application.ApplicationInfo; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.NativeLauncher; import de.tobias.utils.application.container.PathType; @@ -35,10 +40,12 @@ import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; +import javafx.scene.control.ComboBox; import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.ProgressIndicator; import javafx.scene.image.Image; +import javafx.scene.image.ImageView; import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window; @@ -50,7 +57,6 @@ public class UpdateTabViewController extends SettingsTabViewController { private static final String UPDATER_EXE = "Updater.exe"; @FXML private Label currentVersionLabel; - @FXML private Label newVersionLabel; @FXML private CheckBox automaticSearchCheckBox; @FXML private Button manualSearchButton; @@ -58,35 +64,46 @@ public class UpdateTabViewController extends SettingsTabViewController { @FXML private ListView<Updatable> openUpdateList; @FXML private Button updateButton; + @FXML private ComboBox<UpdateChannel> updateChannelComboBox; + + @FXML private Label infoCLabel; + @FXML private Label infoELabel; + + // Placeholder for List private ProgressIndicator progressIndecator; private Label placeholderLabel; public UpdateTabViewController() { super("updateTab", "de/tobias/playpad/assets/view/option/", PlayPadMain.getUiResourceBundle()); + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + updateChannelComboBox.setValue(profileSettings.getUpdateChannel()); openUpdateList.getItems().setAll(UpdateRegistery.getAvailableUpdates()); updateButton.setDisable(openUpdateList.getItems().isEmpty()); - Worker.runLater(() -> - { - Updatable updater = PlayPadMain.getUpdater(); - updater.checkUpdate(); - Platform.runLater(() -> - { - currentVersionLabel.setText(Localization.getString(Strings.UI_Window_Settings_Updates_CurrentVersion, - updater.getCurrentVersion(), updater.getCurrentBuild())); - newVersionLabel.setText(Localization.getString(Strings.UI_Window_Settings_Updates_CurrentVersion, updater.getNewVersion(), - updater.getNewBuild())); - }); - }); + ApplicationInfo info = ApplicationUtils.getApplication().getInfo(); + String currentVersionString = Localization.getString(Strings.UI_Window_Settings_Updates_CurrentVersion, + info.getVersion(), info.getBuild()); + currentVersionLabel.setText(currentVersionString); } @Override public void init() { openUpdateList.setCellFactory(list -> new UpdateCell()); + updateChannelComboBox.getItems().setAll(UpdateChannel.values()); + updateChannelComboBox.setCellFactory(list -> new EnumCell<>(Strings.Update_Channel_BaseName)); + updateChannelComboBox.setButtonCell(new EnumCell<>(Strings.Update_Channel_BaseName)); + + updateChannelComboBox.valueProperty().addListener((a, b, c) -> { + Profile.currentProfile().getProfileSettings().setUpdateChannel(c); + }); + + infoCLabel.setGraphic(new ImageView("de/tobias/playpad/assets/files/class_obj.png")); + infoELabel.setGraphic(new ImageView("de/tobias/playpad/assets/files/enum_obj.png")); progressIndecator = new ProgressIndicator(-1); - progressIndecator.setMinSize(25, 25); + progressIndecator.setMinSize(75, 75); + progressIndecator.setMaxSize(75, 75); placeholderLabel = new Label(Localization.getString(Strings.UI_Placeholder_Updates)); openUpdateList.setPlaceholder(placeholderLabel); @@ -98,12 +115,27 @@ public class UpdateTabViewController extends SettingsTabViewController { private void manualSearchHandler(ActionEvent event) { openUpdateList.getItems().clear(); - openUpdateList.setPlaceholder(progressIndecator); - UpdateRegistery.lookupUpdates(); - openUpdateList.setPlaceholder(placeholderLabel); + Profile profile = Profile.currentProfile(); + if (profile != null) { + openUpdateList.setPlaceholder(progressIndecator); + + Worker.runLater(() -> { + // Search for updates + try { + UpdateRegistery.lookupUpdates(profile.getProfileSettings().getUpdateChannel()); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + showErrorMessage(Localization.getString(Strings.Error_Update_Download, e.getLocalizedMessage())); + } - openUpdateList.getItems().setAll(UpdateRegistery.getAvailableUpdates()); - updateButton.setDisable(openUpdateList.getItems().isEmpty()); + Platform.runLater(() -> { + openUpdateList.setPlaceholder(placeholderLabel); + openUpdateList.getItems().setAll(UpdateRegistery.getAvailableUpdates()); + updateButton.setDisable(openUpdateList.getItems().isEmpty()); + }); + }); + + } } @FXML @@ -112,77 +144,90 @@ public class UpdateTabViewController extends SettingsTabViewController { } public static void update(Window dialogOwner) { - String parameter = UpdateRegistery - .buildParamaterString(ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, DOWNLOAD_FOLDER).toString()); + String parameter = UpdateRegistery.buildParamaterString( + ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, DOWNLOAD_FOLDER).toString()); if (OS.getType() == OSType.Windows) { - try { - Path fileJar = Paths.get(UPDATER_JAR); - Path fileExe = Paths.get(UPDATER_EXE); - Path fileJarFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); - Path fileExeFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_EXE); - - if (Files.exists(fileJar)) { - startJarFile(parameter, fileJar); - } else if (Files.exists(fileExe)) { - startExeFile(parameter, fileExe); - - } else if (Files.exists(fileJarFolder)) { - startJarFile(parameter, fileJarFolder); - } else if (Files.exists(fileExeFolder)) { - startExeFile(parameter, fileExeFolder); - } else { - UpdaterDialog dialog = new UpdaterDialog(dialogOwner); - dialog.show(); - - Worker.runLater(() -> - { - String updaterURL = ApplicationUtils.getApplication().getInfo().getUserInfo().get(AppUserInfoStrings.UPDATER_PROGRAM) - + UPDATER_EXE; - Path path = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_EXE); - try { - downloadUpdater(updaterURL, path); - startExeFile(parameter, path); - } catch (Exception e) { - e.printStackTrace(); - String errorMessage = Localization.getString(Strings.Error_Update_Download, e.getMessage()); - showErrorMessage(errorMessage, PlayPadPlugin.getImplementation().getIcon(), dialogOwner); - } - }); - } - } catch (Exception ex) { - ex.printStackTrace(); - } + windowsUpdate(dialogOwner, parameter); } else { - try { - Path fileJar = Paths.get(UPDATER_JAR); - Path fileJarFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); - - if (Files.exists(fileJar)) { - startJarFile(parameter, fileJar); - } else if (Files.exists(fileJarFolder)) { - startJarFile(parameter, fileJarFolder); - } else { - UpdaterDialog dialog = new UpdaterDialog(dialogOwner); - dialog.show(); - - Worker.runLater(() -> - { - String updaterURL = ApplicationUtils.getApplication().getInfo().getUserInfo().get(AppUserInfoStrings.UPDATER_PROGRAM) - + UPDATER_JAR; - Path path = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); - try { - downloadUpdater(updaterURL, path); - startJarFile(parameter, path); - } catch (Exception e) { - e.printStackTrace(); - String errorMessage = Localization.getString(Strings.Error_Update_Download, e.getMessage()); - showErrorMessage(errorMessage, PlayPadPlugin.getImplementation().getIcon(), dialogOwner); - } - }); - } - } catch (Exception ex) { - ex.printStackTrace(); + macUpdate(dialogOwner, parameter); + } + } + + /** + * Perform Mac Update and if needed download the jar updater. + * + * @param dialogOwner + * Owner window + * @param parameter + */ + private static void macUpdate(Window dialogOwner, String parameter) { + try { + Path fileJar = Paths.get(UPDATER_JAR); + Path fileJarFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); + + if (Files.exists(fileJar)) { + startJarFile(parameter, fileJar); + } else if (Files.exists(fileJarFolder)) { + startJarFile(parameter, fileJarFolder); + } else { + UpdaterDialog dialog = new UpdaterDialog(dialogOwner); + dialog.show(); + + Worker.runLater(() -> { + String updaterURL = ApplicationUtils.getApplication().getInfo().getUserInfo() + .get(AppUserInfoStrings.UPDATER_PROGRAM) + UPDATER_JAR; + Path path = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); + try { + downloadUpdater(updaterURL, path); + startJarFile(parameter, path); + } catch (Exception e) { + e.printStackTrace(); + String errorMessage = Localization.getString(Strings.Error_Update_Download, e.getMessage()); + showErrorMessage(errorMessage, PlayPadPlugin.getImplementation().getIcon(), dialogOwner); + } + }); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + private static void windowsUpdate(Window dialogOwner, String parameter) { + try { + Path fileJar = Paths.get(UPDATER_JAR); + Path fileExe = Paths.get(UPDATER_EXE); + Path fileJarFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_JAR); + Path fileExeFolder = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_EXE); + + if (Files.exists(fileJar)) { + startJarFile(parameter, fileJar); + } else if (Files.exists(fileExe)) { + startExeFile(parameter, fileExe); + + } else if (Files.exists(fileJarFolder)) { + startJarFile(parameter, fileJarFolder); + } else if (Files.exists(fileExeFolder)) { + startExeFile(parameter, fileExeFolder); + } else { + UpdaterDialog dialog = new UpdaterDialog(dialogOwner); + dialog.show(); + + Worker.runLater(() -> { + ApplicationInfo info = ApplicationUtils.getApplication().getInfo(); + String updaterURL = info.getUserInfo().get(AppUserInfoStrings.UPDATER_PROGRAM) + UPDATER_EXE; + Path path = ApplicationUtils.getApplication().getPath(PathType.DOWNLOAD, UPDATER_EXE); + try { + downloadUpdater(updaterURL, path); + startExeFile(parameter, path); + } catch (Exception e) { + e.printStackTrace(); + String errorMessage = Localization.getString(Strings.Error_Update_Download, e.getMessage()); + showErrorMessage(errorMessage, PlayPadPlugin.getImplementation().getIcon(), dialogOwner); + } + }); } + } catch (Exception ex) { + ex.printStackTrace(); } } @@ -211,7 +256,8 @@ public class UpdateTabViewController extends SettingsTabViewController { } private static void startJarFile(String parameter, Path fileJarFolder) throws IOException { - ProcessBuilder builder = new ProcessBuilder("java", "-jar", fileJarFolder.toAbsolutePath().toString(), parameter); + ProcessBuilder builder = new ProcessBuilder("java", "-jar", fileJarFolder.toAbsolutePath().toString(), + parameter); builder.start(); System.exit(0); } diff --git a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java index db0b7ea64dccd1216bba78ddf58a5c80854589f1..7e55988c26d8adbfa59e1b5494c3766d760595dd 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java @@ -20,6 +20,10 @@ import de.tobias.utils.application.container.PathType; public class Profile { + private static final String PROFILE_SETTINGS_XML = "ProfileSettings.xml"; + 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,}"; private static List<ProfileListener> listeners = new ArrayList<>(); @@ -97,10 +101,9 @@ public class Profile { if (Files.exists(app.getPath(PathType.CONFIGURATION, ref.getFileName()))) { - ProfileSettings profileSettings = ProfileSettings - .load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "ProfileSettings.xml")); + ProfileSettings profileSettings = ProfileSettings.load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), PROFILE_SETTINGS_XML)); HashMap<String, GlobalLayout> layouts = GlobalLayout - .loadGlobalLayout(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "Layout.xml")); + .loadGlobalLayout(app.getPath(PathType.CONFIGURATION, ref.getFileName(), LAYOUT_XML)); profile.profileSettings = profileSettings; profile.layouts = layouts; @@ -116,7 +119,7 @@ public class Profile { }); // Mapping erst danach, weil das auf current Profile zugreifen muss - MappingList mappings = MappingList.load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "Mapping.xml"), profile); + MappingList mappings = MappingList.load(app.getPath(PathType.CONFIGURATION, ref.getFileName(), MAPPING_XML), profile); profile.mappings = mappings; setCurrentProfile(profile); @@ -141,9 +144,14 @@ public class Profile { if (Files.notExists(root)) Files.createDirectories(root); - profileSettings.save(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "ProfileSettings.xml")); - mappings.save(app.getPath(PathType.CONFIGURATION, ref.getFileName(), "Mapping.xml")); - GlobalLayout.saveGlobal(layouts, app.getPath(PathType.CONFIGURATION, ref.getFileName(), "Layout.xml")); + profileSettings.save(getProfilePath(PROFILE_SETTINGS_XML)); + mappings.save(getProfilePath(MAPPING_XML)); + GlobalLayout.saveGlobal(layouts, getProfilePath(LAYOUT_XML)); + } + + private Path getProfilePath(String fileName) { + App app = ApplicationUtils.getApplication(); + return app.getPath(PathType.CONFIGURATION, ref.getFileName(), fileName); } @Override diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java index 3cf852a167e03b5c83f619f2c63583c4fe51e0eb..78bc49db58cb5e8c6e833852a22ba3eed12fb7b2 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java @@ -20,6 +20,7 @@ import de.tobias.playpad.layout.LayoutRegistry; import de.tobias.playpad.pad.Fade; import de.tobias.playpad.pad.TimeMode; import de.tobias.playpad.pad.Warning; +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; @@ -73,8 +74,9 @@ public class ProfileSettings implements SettingsSerializable { // Folder @Storable private Path cachePath = ApplicationUtils.getApplication().getPath(PathType.CACHE); - // Update + // Update - TODO GlobalSettings @Storable private boolean autoUpdate = true; + @Storable private UpdateChannel updateChannel = UpdateChannel.STABLE; public boolean isLocked() { return lockedProperty.get(); @@ -179,6 +181,10 @@ public class ProfileSettings implements SettingsSerializable { return autoUpdate; } + public UpdateChannel getUpdateChannel() { + return updateChannel; + } + // Setter public void setMidiDeviceName(String midiDevice) { this.midiDevice = midiDevice; @@ -258,6 +264,10 @@ public class ProfileSettings implements SettingsSerializable { this.autoUpdate = autoUpdate; } + public void setUpdateChannel(UpdateChannel updateChannel) { + this.updateChannel = updateChannel; + } + // Properties public DoubleProperty volumeProperty() { return volumeProperty; @@ -266,6 +276,7 @@ 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"; @@ -378,6 +389,10 @@ public class ProfileSettings implements SettingsSerializable { 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; } @@ -410,7 +425,7 @@ public class ProfileSettings implements SettingsSerializable { liveElement.addAttribute(LIVE_MODE_DRAG_ATTR, String.valueOf(liveModeDrag)); liveElement.addAttribute(LIVE_MODE_FILE_ATTR, String.valueOf(liveModeFile)); liveElement.addAttribute(LIVE_MODE_SETTINGS_ATTR, String.valueOf(liveModeSettings)); - + root.addElement(WINDOW_ALWAYS_ON_TOP_ELEMENT).addText(String.valueOf(windowAlwaysOnTop)); // Audio @@ -424,7 +439,10 @@ public class ProfileSettings implements SettingsSerializable { // 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); diff --git a/PlayWallCore/src/de/tobias/playpad/Updatable.java b/PlayWallCore/src/de/tobias/playpad/update/Updatable.java similarity index 56% rename from PlayWallCore/src/de/tobias/playpad/Updatable.java rename to PlayWallCore/src/de/tobias/playpad/update/Updatable.java index 8ae1166bbd82243e86f5db429da899cbea1e722b..88c493aec8cd4b9741f2e46dadfb71df421aec90 100644 --- a/PlayWallCore/src/de/tobias/playpad/Updatable.java +++ b/PlayWallCore/src/de/tobias/playpad/update/Updatable.java @@ -1,5 +1,7 @@ -package de.tobias.playpad; +package de.tobias.playpad.update; +import java.io.IOException; +import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; @@ -13,7 +15,9 @@ public interface Updatable { public String getNewVersion(); - public boolean checkUpdate(); + public boolean isUpdateAvailable(); + + public void loadInformation(UpdateChannel channel) throws IOException, URISyntaxException; public URL getDownloadPath(); diff --git a/PlayWallCore/src/de/tobias/playpad/update/UpdateChannel.java b/PlayWallCore/src/de/tobias/playpad/update/UpdateChannel.java new file mode 100644 index 0000000000000000000000000000000000000000..ca0367b83d6e1209be9076f625caafde2e759364 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/update/UpdateChannel.java @@ -0,0 +1,18 @@ +package de.tobias.playpad.update; + +public enum UpdateChannel { + + STABLE("stable"), + BETA("beta"); + + private String name; + + private UpdateChannel(String name) { + this.name = name; + } + + @Override + public String toString() { + return name; + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/UpdateRegistery.java b/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java similarity index 86% rename from PlayWallCore/src/de/tobias/playpad/UpdateRegistery.java rename to PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java index 2ce10162e60434ca84d3b2fa6e355e5cfeb8341a..d49d153063469af73821d44a0b2232cd626e629b 100644 --- a/PlayWallCore/src/de/tobias/playpad/UpdateRegistery.java +++ b/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java @@ -1,5 +1,6 @@ -package de.tobias.playpad; +package de.tobias.playpad.update; +import java.io.IOException; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; @@ -22,10 +23,11 @@ public class UpdateRegistery { return availableUpdates; } - public static List<Updatable> lookupUpdates() { + public static List<Updatable> lookupUpdates(UpdateChannel channel) throws IOException, URISyntaxException { availableUpdates.clear(); for (Updatable updatable : UpdateRegistery.updatables) { - if (updatable.checkUpdate()) { + updatable.loadInformation(channel); + if (updatable.isUpdateAvailable()) { availableUpdates.add(updatable); } } @@ -38,6 +40,8 @@ public class UpdateRegistery { private static final String URL = "url"; private static final String EXECUTE_FILE = "executePath"; + + public static String buildParamaterString(String downloadPath) { JSONObject data = new JSONObject(); data.put(DOWNLOAD_PATH, downloadPath);