diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties index 2d94039b6ff8ca449636c55d893d31ab0eff5839..986c8bfdf2e6336278cee61aa15e3d09fc8bc981 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties @@ -169,6 +169,7 @@ Error.Midi.Send=Der Midi Befehl konnte nicht gesendet werden. ({}) # Error - Plugins Error.Plugins.Download=Die Erweiterung {} konnte nicht geladen werden. Error.Plugins.Avaiable=Es sind keine Erweiterungen f�r diesen Update-Kanal verf�gbar. +Error.Plugins.Missing=Es fehlen Plugins. Bitte installiere die fehlenden Plugins, damit das Projekt verlustfrei ge�ffnet werden kann. Alle ben�tigten Plugins sind gleich aufgelistet. #Mapper Mapper.Keyboard.Name=Tastatur diff --git a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java index 742a63bb0f84e2200bdc3ac579396988abd9b61a..83a786bb19b6698b8ecda075b83d11adb95a3cab 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java @@ -9,6 +9,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Optional; @@ -22,25 +23,32 @@ 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.AdvancedPlugin; +import de.tobias.playpad.plugin.Module; 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.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.main.IMainViewController; import de.tobias.playpad.viewcontroller.main.MainViewController; import de.tobias.playpad.viewcontroller.option.IProfileSettingsViewController; +import de.tobias.utils.application.App; 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.Plugin; import net.xeoh.plugins.base.PluginManager; import net.xeoh.plugins.base.impl.PluginManagerFactory; +import net.xeoh.plugins.base.util.PluginManagerUtil; public class PlayPadImpl implements PlayPad { @@ -57,14 +65,23 @@ public class PlayPadImpl implements PlayPad { private MainViewController mainViewController; private Project currentProject; + private static Module module; protected GlobalSettings globalSettings; + private Set<Module> modules; + public PlayPadImpl(GlobalSettings globalSettings) { + App app = ApplicationUtils.getApplication(); + module = new Module(app.getInfo().getName(), app.getInfo().getIdentifier()); + pluginManager = PluginManagerFactory.createPluginManager(); deletedPlugins = new HashSet<>(); + modules = new HashSet<>(); this.globalSettings = globalSettings; + + getModules().add(module); // Add Main Module } @Override @@ -189,13 +206,27 @@ public class PlayPadImpl implements PlayPad { // TODO Auto-generated catch block e.printStackTrace(); } - + pluginManager.shutdown(); Worker.shutdown(); } public void loadPlugin(URI uri) { pluginManager.addPluginsFrom(uri); + + // Registriert Funktionen aus Plugin (Module und Update, ...) + PluginManagerUtil util = new PluginManagerUtil(pluginManager); + Collection<Plugin> plugins = util.getPlugins(); + for (Plugin plugin : plugins) { + if (plugin instanceof AdvancedPlugin) { + AdvancedPlugin advancedPlugin = (AdvancedPlugin) plugin; + Module module = advancedPlugin.getModule(); + Updatable updatable = advancedPlugin.getUpdatable(); + + modules.add(module); + UpdateRegistery.registerUpdateable(updatable); + } + } } @Override @@ -214,11 +245,11 @@ public class PlayPadImpl implements PlayPad { public Project getCurrentProject() { return currentProject; } - + public void startup(ResourceBundle resourceBundle) { registerComponents(resourceBundle); } - + private void registerComponents(ResourceBundle resourceBundle) { // Midi DeviceRegistry.getFactoryInstance().registerDevice(PD12.NAME, PD12.class); @@ -227,14 +258,14 @@ public class PlayPadImpl implements PlayPad { // 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"); + registryCollection.getActions().loadComponentsFromFile("de/tobias/playpad/components/Actions.xml", module); + registryCollection.getAudioHandlers().loadComponentsFromFile("de/tobias/playpad/components/AudioHandler.xml", module); + registryCollection.getDragModes().loadComponentsFromFile("de/tobias/playpad/components/DragMode.xml", module); + registryCollection.getDesigns().loadComponentsFromFile("de/tobias/playpad/components/Design.xml", module); + registryCollection.getMappers().loadComponentsFromFile("de/tobias/playpad/components/Mapper.xml", module); + registryCollection.getPadContents().loadComponentsFromFile("de/tobias/playpad/components/PadContent.xml", module); + registryCollection.getTriggerItems().loadComponentsFromFile("de/tobias/playpad/components/Trigger.xml", module); + registryCollection.getMainLayouts().loadComponentsFromFile("de/tobias/playpad/components/Layout.xml", module); // Set Default registryCollection.getAudioHandlers().setDefaultID(JavaFXAudioHandler.TYPE); @@ -250,5 +281,10 @@ public class PlayPadImpl implements PlayPad { // Mapper MapperRegistry.setOverviewViewController(new MapperOverviewViewController()); + + } + + public Set<Module> getModules() { + return modules; } } diff --git a/PlayWall/src/de/tobias/playpad/Strings.java b/PlayWall/src/de/tobias/playpad/Strings.java index ecd9bf62c80aef675ee7fd54034d9ed29e3282c5..8dfd96d7b1495d0065e465f69599fc655625a894 100644 --- a/PlayWall/src/de/tobias/playpad/Strings.java +++ b/PlayWall/src/de/tobias/playpad/Strings.java @@ -163,6 +163,7 @@ public class Strings { // Error - Plugins @Deprecated public static final String Error_Plugins_Download = "Error.Plugins.Download"; public static final String Error_Plugins_Available = "Error.Plugins.Available"; + public static final String Error_Plugins_Missing = "Error.Plugins.Missing"; // Mapper public static final String Mapper_Keyboard_Name = "Mapper.Keyboard.Name"; diff --git a/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapperConnect.java b/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapperConnect.java index f9f169dd42791b3c686c9656ad5056ca0c6098fe..e70c964c141cca12ef407f30e7c0a79e9cc604fb 100644 --- a/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapperConnect.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapperConnect.java @@ -20,7 +20,7 @@ public class MidiMapperConnect extends MapperConnect implements MapperConnectFee @Override public void initFeedbackType() { - Midi.getInstance().getMidiDevice().ifPresent(device -> device.initFeedback()); + Midi.getInstance().getMidiDevice().ifPresent(device -> device.initDevice()); } @Override diff --git a/PlayWall/src/de/tobias/playpad/midi/device/PD12.java b/PlayWall/src/de/tobias/playpad/midi/device/PD12.java index df4ceb01d9a4883b17752afdbab848abdae5c03d..40c050e4f26906dac9be42609b06c028bc418835 100644 --- a/PlayWall/src/de/tobias/playpad/midi/device/PD12.java +++ b/PlayWall/src/de/tobias/playpad/midi/device/PD12.java @@ -43,7 +43,7 @@ public class PD12 extends Device { public void handleFeedback(FeedbackMessage type, int key, Feedback feedback) {} @Override - public void initFeedback() {} + public void initDevice() {} @Override public void clearFeedback() {} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java index 7c60c0c172218034755d41d1b90b75164cd9c5fe..45ed705910a460109cd28abea48f6712f25df41d 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java @@ -11,19 +11,21 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.project.ProfileChooseable; +import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectImporter; import de.tobias.playpad.project.ProjectNotFoundException; -import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileNotFoundException; import de.tobias.playpad.viewcontroller.cell.ProjectCell; 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.ProfileChooseDialog; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.ui.ViewController; +import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Alert; @@ -106,7 +108,7 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { stage.setTitle(getString(Strings.UI_Dialog_Launch_Title)); PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); - + stage.setResizable(false); stage.setWidth(650); stage.show(); @@ -184,12 +186,19 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { } /** - * Launch a project and close this view. + * Öffnet ein Project und zeigt es im MainView an. Zudem wird as entsprechende Profile geladen und geprüft ob Module (Plugins) fehlen. * * @param ref * Project to launch */ private void launchProject(ProjectReference ref) { + // Es fehlen Module + if (!ref.getMissedModules().isEmpty()) { + showInfoMessage(Localization.getString(Strings.Error_Plugins_Missing)); + PluginViewController controller = new PluginViewController(getStage(), ref.getMissedModules()); + controller.getStage().showAndWait(); + } + try { Project project = Project.load(ref, true, this); PlayPadMain.getProgramInstance().openProject(project); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/PluginCell.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/PluginCell.java index 6deea2a19ee6d00415ee5d33d791fb75f90439ec..04a4b7619c5ea2e4e317884d0844276899e22793 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/PluginCell.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/PluginCell.java @@ -1,18 +1,15 @@ package de.tobias.playpad.viewcontroller.cell; -import java.io.IOException; -import java.net.URL; -import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.plugin.Plugin; +import de.tobias.playpad.plugin.PluginDescription; import de.tobias.playpad.plugin.Plugins; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; +import de.tobias.utils.util.Worker; +import javafx.application.Platform; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.geometry.Pos; @@ -20,9 +17,9 @@ import javafx.scene.control.CheckBox; import javafx.scene.control.ListCell; import javafx.scene.layout.HBox; -public class PluginCell extends ListCell<Plugin> implements ChangeListener<Boolean> { +public class PluginCell extends ListCell<PluginDescription> implements ChangeListener<Boolean> { - private Plugin plugin; + private PluginDescription plugin; private HBox buttons; private CheckBox checkBox; @@ -36,7 +33,7 @@ public class PluginCell extends ListCell<Plugin> implements ChangeListener<Boole } @Override - protected void updateItem(Plugin item, boolean empty) { + protected void updateItem(PluginDescription item, boolean empty) { super.updateItem(item, empty); if (!empty) { this.plugin = item; @@ -58,51 +55,22 @@ public class PluginCell extends ListCell<Plugin> implements ChangeListener<Boole Path path = app.getPath(PathType.LIBRARY, plugin.getFileName()); if (newValue) { // Wurde Aktiviert - downloadPlugin(plugin, path); + Worker.runLater(() -> + { + Plugins.downloadPlugin(plugin, path); - // Dependencies - loadDependencies(app); + // Dependencies + Plugins.loadDependencies(plugin); - // Add Plugin to classpath - PlayPadMain.getProgramInstance().loadPlugin(path.toUri()); + // Add Plugin to classpath + Platform.runLater(() -> PlayPadMain.getProgramInstance().loadPlugin(path.toUri())); // FX Thread, damit Plugins GUI Zeug + // gleich auf dem richtigen Thread + // haben, sonst müssen sie den Worker + // nutzen + }); } else { // Deaktivieren PlayPadMain.getProgramInstance().addDeletedPlugin(path); } } - - private void loadDependencies(App app) { - List<Plugin> dependencies = findDependencies(); - dependencies.forEach(p -> - { - Path decPath = app.getPath(PathType.LIBRARY, p.getFileName()); - downloadPlugin(p, decPath); - - // Add Plugin to classpath - PlayPadMain.getProgramInstance().loadPlugin(decPath.toUri()); - }); - } - - private List<Plugin> findDependencies() { - List<Plugin> plugins = new ArrayList<>(); - for (String dependencyName : plugin.getDependencies()) { - for (Plugin plugin : Plugins.getPlugins()) { - if (plugin.getName().equals(dependencyName)) { - plugins.add(plugin); - } - } - } - return plugins; - } - - private void downloadPlugin(Plugin plugin, Path path) { - if (Files.notExists(path)) { - try { - Files.createDirectories(path.getParent()); - Files.copy(new URL(plugin.getUrl()).openStream(), path); - } catch (IOException e) { - e.printStackTrace(); - } - } - } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java index 7100364822a123445647c6b63f5efe6d9dbf340f..6d132b21054e346355bf8dc1a1c6fa30f1bd882e 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java @@ -60,7 +60,7 @@ public class ProjectCell extends ListCell<ProjectReference> { // File not Exists Path path = ref.getProjectPath(); - if (Files.notExists(path)) { + if (Files.notExists(path) || !ref.getMissedModules().isEmpty()) { FontIcon graphics = new FontIcon(FontAwesomeType.WARNING); graphics.setColor(Color.RED); rootBox.getChildren().add(graphics); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/AutoUpdateDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/AutoUpdateDialog.java index f3d0fb89824c60c308730e1c0a365442544023d0..ea4b89db2e8c5e7d0095af096e7d341257faf87f 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/AutoUpdateDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/AutoUpdateDialog.java @@ -1,6 +1,6 @@ package de.tobias.playpad.viewcontroller.dialog; -import java.util.List; +import java.util.Set; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; @@ -16,7 +16,7 @@ public class AutoUpdateDialog extends AdvancedDialog { public AutoUpdateDialog(Window owner) { super(owner); - List<Updatable> updates = UpdateRegistery.getAvailableUpdates(); + Set<Updatable> updates = UpdateRegistery.getAvailableUpdates(); StringBuilder builder = new StringBuilder(); for (Updatable update : updates) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/MappingListViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/MappingListViewController.java index b59e10fc3ea267ae949d7f7d8ac8fb89186dc1b4..cafa9abe59255bcaee8469b32dc3e7d3ac3d9592 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/MappingListViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/MappingListViewController.java @@ -117,7 +117,7 @@ public class MappingListViewController extends ViewController { @FXML private void addButtonHandler(ActionEvent event) { - Mapping preset = new Mapping(true, Profile.currentProfile()); + Mapping preset = new Mapping(true); mappingList.add(preset); presetsListView.getItems().add(preset); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java index 42341a2c4ebd3b53e96a89c1f079945e4337f675..1f09405add4ba137a97111be62974b61852813f4 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java @@ -3,6 +3,7 @@ package de.tobias.playpad.viewcontroller.dialog; import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.Set; import org.bukkit.configuration.MemorySection; @@ -10,7 +11,8 @@ 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.Module; +import de.tobias.playpad.plugin.PluginDescription; import de.tobias.playpad.plugin.Plugins; import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; @@ -32,10 +34,14 @@ import javafx.stage.Window; public class PluginViewController extends ViewController { - @FXML private ListView<Plugin> pluginListView; + @FXML private ListView<PluginDescription> pluginListView; @FXML private Button finishButton; public PluginViewController(Window owner) { + this(owner, null); + } + + public PluginViewController(Window owner, Set<Module> modules) { super("pluginView", "de/tobias/playpad/assets/dialog/", null, PlayPadMain.getUiResourceBundle()); getStage().initOwner(owner); @@ -60,18 +66,31 @@ public class PluginViewController extends ViewController { return; } - List<Plugin> plugins = Plugins.load(pluginInfoURL, true); + List<PluginDescription> plugins = Plugins.loadDescriptionFromServer(pluginInfoURL, true); Collections.sort(plugins); Platform.runLater(() -> { - pluginListView.getItems().setAll(plugins); + // Nur bestimmte Plugins zur Liste (die, die Fehlen) + if (modules != null) { + for (PluginDescription plugin : plugins) { + for (Module module : modules) { + if (module.identifier.equals(plugin.getId())) { + pluginListView.getItems().add(plugin); + } + } + } + } else { + // Alle Plugins zur Liste + pluginListView.getItems().setAll(plugins); + } }); } catch (IOException e) { e.printStackTrace(); showErrorMessage(Localization.getString(Strings.Error_Standard_Gen), PlayPadMain.stageIcon); } }); + } @Override @@ -92,7 +111,8 @@ public class PluginViewController extends ViewController { stage.setTitle(Localization.getString(Strings.UI_Dialog_Plugins_Title)); - Profile.currentProfile().currentLayout().applyCss(getStage()); + if (Profile.currentProfile() != null) + Profile.currentProfile().currentLayout().applyCss(getStage()); } @FXML diff --git a/PlayWallCore/src/de/tobias/playpad/PlayPad.java b/PlayWallCore/src/de/tobias/playpad/PlayPad.java index 7326cfbbde2f9e11be3ef46f1bb3670131f0eb8b..4f08b132929fe17e543caddde537f753800049f4 100644 --- a/PlayWallCore/src/de/tobias/playpad/PlayPad.java +++ b/PlayWallCore/src/de/tobias/playpad/PlayPad.java @@ -1,9 +1,11 @@ package de.tobias.playpad; import java.net.URI; +import java.util.Collection; import java.util.List; import java.util.Optional; +import de.tobias.playpad.plugin.Module; import de.tobias.playpad.plugin.PadListener; import de.tobias.playpad.plugin.SettingsListener; import de.tobias.playpad.plugin.WindowListener; @@ -113,4 +115,11 @@ public interface PlayPad { * @return Global Settings */ public GlobalSettings getGlobalSettings(); + + /** + * Gibt alle aktiven Module zurück. + * + * @return Module + */ + public Collection<Module> getModules(); } diff --git a/PlayWallCore/src/de/tobias/playpad/Updatable.java b/PlayWallCore/src/de/tobias/playpad/Updatable.java index 8d3b80e9f9bc64c26dd4b5d711ec78e30884304b..7b3faf36dedc3414f981e5262b0aaf333f6d59f7 100644 --- a/PlayWallCore/src/de/tobias/playpad/Updatable.java +++ b/PlayWallCore/src/de/tobias/playpad/Updatable.java @@ -4,14 +4,12 @@ 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. + * 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 { diff --git a/PlayWallCore/src/de/tobias/playpad/action/ActionSerializer.java b/PlayWallCore/src/de/tobias/playpad/action/ActionSerializer.java index 4fe1c68b65c8da6c67d6bcd5658c5dd7f8805525..93e5df2219e338f567de94f832a0e6914c6578cd 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/ActionSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/action/ActionSerializer.java @@ -7,7 +7,9 @@ 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.plugin.Module; import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.settings.Profile; import de.tobias.utils.xml.XMLDeserializer; import de.tobias.utils.xml.XMLHandler; import de.tobias.utils.xml.XMLSerializer; @@ -18,11 +20,25 @@ public class ActionSerializer implements XMLSerializer<Action>, XMLDeserializer< private static final String MAPPER = "Mapper"; private Mapping mapping; + private Profile profile; public ActionSerializer(Mapping mapping) { this.mapping = mapping; } + /** + * Speichern. + * + * @param mapping + * mapping + * @param profile + * profile + */ + public ActionSerializer(Mapping mapping, Profile profile) { + this.mapping = mapping; + this.profile = profile; + } + @Override public Action loadElement(Element element) { String tpye = element.attributeValue(ACTION_TYPE); @@ -49,6 +65,11 @@ public class ActionSerializer implements XMLSerializer<Action>, XMLDeserializer< @Override public void saveElement(Element newElement, Action data) { + Module module = PlayPadPlugin.getRegistryCollection().getActions().getModule(data.getType()); + if (profile != null) { + profile.getRef().addRequestedModule(module); + } + newElement.addAttribute(ACTION_TYPE, data.getType()); data.save(newElement); diff --git a/PlayWallCore/src/de/tobias/playpad/action/Mapping.java b/PlayWallCore/src/de/tobias/playpad/action/Mapping.java index 60688949f3462b2c15d93090150963d05d607299..5198bfea6be0241c01f87558970b3d58b2011e2e 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/Mapping.java +++ b/PlayWallCore/src/de/tobias/playpad/action/Mapping.java @@ -26,7 +26,7 @@ public class Mapping implements Cloneable, ActionDisplayable { private UUID uuid; private HashMap<Action, List<Mapper>> mapping; - public Mapping(boolean init, Profile profile) { + public Mapping(boolean init) { mapping = new HashMap<>(); if (init) { name = "Default"; diff --git a/PlayWallCore/src/de/tobias/playpad/action/MappingList.java b/PlayWallCore/src/de/tobias/playpad/action/MappingList.java index ab8e325ed73e463a7dbf7aa0bab8788acf9e69d9..3951f1c53a969d86842398b62ddcf58dd76ad910 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/MappingList.java +++ b/PlayWallCore/src/de/tobias/playpad/action/MappingList.java @@ -2,6 +2,7 @@ package de.tobias.playpad.action; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.lang.ref.WeakReference; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -25,9 +26,12 @@ public class MappingList extends ArrayList<Mapping> { private static final long serialVersionUID = 1L; private UUID activeMapping; + private WeakReference<Profile> profile; public MappingList(Profile profile) { - add(new Mapping(true, profile)); + add(new Mapping(true)); + + this.profile = new WeakReference<Profile>(profile); } public Mapping getActiveMapping() { @@ -79,7 +83,7 @@ public class MappingList extends ArrayList<Mapping> { // Init mappings, if non exists if (mappings.size() == 0) { - mappings.add(new Mapping(true, profile)); + mappings.add(new Mapping(true)); } return mappings; @@ -98,7 +102,7 @@ public class MappingList extends ArrayList<Mapping> { } XMLHandler<Mapping> handler = new XMLHandler<>(rootElement); - handler.saveElements(MAPPING, this, new MappingSerializer()); + handler.saveElements(MAPPING, this, new MappingSerializer(profile.get())); if (Files.notExists(path)) { Files.createDirectories(path.getParent()); @@ -109,7 +113,7 @@ public class MappingList extends ArrayList<Mapping> { } public static Mapping importMappingPreset(Path path, Profile profile) throws DocumentException, IOException { - Mapping mapping = new Mapping(false, profile); + Mapping mapping = new Mapping(false); SAXReader reader = new SAXReader(); Document document = reader.read(Files.newInputStream(path)); @@ -126,7 +130,7 @@ public class MappingList extends ArrayList<Mapping> { Document docoment = DocumentHelper.createDocument(); Element rootElement = docoment.addElement(MAPPING); - MappingSerializer mappingSerializer = new MappingSerializer(); + MappingSerializer mappingSerializer = new MappingSerializer(null); mappingSerializer.saveElement(rootElement, preset); XMLWriter writer = new XMLWriter(Files.newOutputStream(path), OutputFormat.createPrettyPrint()); diff --git a/PlayWallCore/src/de/tobias/playpad/action/MappingSerializer.java b/PlayWallCore/src/de/tobias/playpad/action/MappingSerializer.java index aea0d32e765d31b6e73818d9c72acff261f7e1c7..c74dfad67f9b5ecc28d280c8728bc37a097e42e2 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/MappingSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/action/MappingSerializer.java @@ -17,17 +17,13 @@ public class MappingSerializer implements XMLSerializer<Mapping>, XMLDeserialize private Profile profile; - public MappingSerializer() { - - } - public MappingSerializer(Profile profile) { this.profile = profile; } @Override public Mapping loadElement(Element element) { - Mapping mapping = new Mapping(false, profile); + Mapping mapping = new Mapping(false); mapping.setName(element.attributeValue(NAME)); @@ -50,6 +46,6 @@ public class MappingSerializer implements XMLSerializer<Mapping>, XMLDeserialize newElement.addAttribute(UUID_NAME, data.getUuid().toString()); XMLHandler<Action> handler = new XMLHandler<>(newElement); - handler.saveElements(ACTION, data.getActions(), new ActionSerializer(data)); + handler.saveElements(ACTION, data.getActions(), new ActionSerializer(data, profile)); } } diff --git a/PlayWallCore/src/de/tobias/playpad/action/mididevice/Device.java b/PlayWallCore/src/de/tobias/playpad/action/mididevice/Device.java index e8d46339804f3024b3d0726fa1e8e2981e17f522..8a55c904fdb5b4d32c5b0dc7c7bbd82f61fd3dcd 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/mididevice/Device.java +++ b/PlayWallCore/src/de/tobias/playpad/action/mididevice/Device.java @@ -35,7 +35,7 @@ public abstract class Device extends EventDispatcher implements Listener { public abstract DisplayableFeedbackColor getColor(int id); - public abstract void initFeedback(); + public abstract void initDevice(); public abstract void handleFeedback(FeedbackMessage type, int key, Feedback feedback); diff --git a/PlayWallCore/src/de/tobias/playpad/midi/device/DefaultDevice.java b/PlayWallCore/src/de/tobias/playpad/midi/device/DefaultDevice.java index 5fa72cb64767217eec3e45ff676ef9694804ce61..af8a3460898abbd3c1238f6e1839dadcb9d3980a 100644 --- a/PlayWallCore/src/de/tobias/playpad/midi/device/DefaultDevice.java +++ b/PlayWallCore/src/de/tobias/playpad/midi/device/DefaultDevice.java @@ -21,7 +21,7 @@ public class DefaultDevice extends Device { public void handleFeedback(FeedbackMessage type, int key, Feedback feedback) {} @Override - public void initFeedback() {} + public void initDevice() {} @Override public void clearFeedback() {} diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java index bb759b53ca3f33e560cedb1514111f8749500151..87f7d7a857d90cc61da1639b9dd7bcab56e68b28 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java @@ -9,6 +9,7 @@ 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.PadContentConnect; +import de.tobias.playpad.plugin.Module; import de.tobias.playpad.project.Project; import de.tobias.playpad.registry.DefaultRegistry; import de.tobias.playpad.registry.NoSuchComponentException; @@ -53,9 +54,6 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { this.project = project; } - public PadSerializer() { - } - @Override public Pad loadElement(Element element) { Pad pad = new Pad(project); @@ -205,10 +203,14 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { } // Content - if (data.getContent() != null) { + PadContent content = data.getContent(); + if (content != null) { Element contentElement = element.addElement(CONTENT_ELEMENT); - contentElement.addAttribute(CONTENT_TYPE_ATTR, data.getContent().getType()); - data.getContent().save(contentElement); + contentElement.addAttribute(CONTENT_TYPE_ATTR, content.getType()); + content.save(contentElement); + + Module module = PlayPadPlugin.getRegistryCollection().getPadContents().getModule(content.getType()); + project.getProjectReference().addRequestedModule(module); } } } diff --git a/PlayWallCore/src/de/tobias/playpad/plugin/AdvancedPlugin.java b/PlayWallCore/src/de/tobias/playpad/plugin/AdvancedPlugin.java new file mode 100644 index 0000000000000000000000000000000000000000..619a86a08c3f2387b4427d47ccf87a739c5ad412 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/plugin/AdvancedPlugin.java @@ -0,0 +1,16 @@ +package de.tobias.playpad.plugin; + +import de.tobias.playpad.update.Updatable; + +/** + * Schnittatelle, von der Plugins erben, damit diese alle notwendigen Services unterstützen. + * + * @author tobias - s0553746 + * + */ +public interface AdvancedPlugin extends net.xeoh.plugins.base.Plugin { + + public Module getModule(); + + public Updatable getUpdatable(); +} diff --git a/PlayWallCore/src/de/tobias/playpad/plugin/Module.java b/PlayWallCore/src/de/tobias/playpad/plugin/Module.java new file mode 100644 index 0000000000000000000000000000000000000000..19c04e6d4ffebce95722c596236ce2207de0cf26 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/plugin/Module.java @@ -0,0 +1,55 @@ +package de.tobias.playpad.plugin; + +/** + * Ein Modul beschreibt ein Plugin. Es wird verwendet, um Components der Registry einem Mpdul zuzuordnen. + * + * @author tobias - s0553746 + * + */ +public class Module { + + public final String name; + public final String identifier; + + public Module(String name, String identifier) { + this.name = name; + this.identifier = identifier; + } + + @Override + public String toString() { + return "Module [name=" + name + ", identifier=" + identifier + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((identifier == null) ? 0 : identifier.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Module other = (Module) obj; + if (identifier == null) { + if (other.identifier != null) + return false; + } else if (!identifier.equals(other.identifier)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + +} diff --git a/PlayWallCore/src/de/tobias/playpad/plugin/ModuleSerializer.java b/PlayWallCore/src/de/tobias/playpad/plugin/ModuleSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..109e0abf696f4d139df9cd3e3896ba65b2528670 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/plugin/ModuleSerializer.java @@ -0,0 +1,25 @@ +package de.tobias.playpad.plugin; + +import org.dom4j.Element; + +import de.tobias.utils.xml.XMLDeserializer; +import de.tobias.utils.xml.XMLSerializer; + +public class ModuleSerializer implements XMLSerializer<Module>, XMLDeserializer<Module> { + + private static final String NAME_ATTR = "name"; + private static final String IDENTIFIER_ATTR = "id"; + + @Override + public Module loadElement(Element element) { + String name = element.attributeValue(NAME_ATTR); + String id = element.attributeValue(IDENTIFIER_ATTR); + return new Module(name, id); + } + + @Override + public void saveElement(Element newElement, Module data) { + newElement.addAttribute(NAME_ATTR, data.name); + newElement.addAttribute(IDENTIFIER_ATTR, data.identifier); + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/plugin/Plugin.java b/PlayWallCore/src/de/tobias/playpad/plugin/PluginDescription.java similarity index 71% rename from PlayWallCore/src/de/tobias/playpad/plugin/Plugin.java rename to PlayWallCore/src/de/tobias/playpad/plugin/PluginDescription.java index fcbe98abe97596e8ecc83b62c0eefa2ebb30d9a6..9b3357a88fb079f30efbb3eef7cac2b06e5abcf4 100644 --- a/PlayWallCore/src/de/tobias/playpad/plugin/Plugin.java +++ b/PlayWallCore/src/de/tobias/playpad/plugin/PluginDescription.java @@ -2,8 +2,9 @@ package de.tobias.playpad.plugin; import java.util.List; -public class Plugin implements Comparable<Plugin> { +public class PluginDescription implements Comparable<PluginDescription> { + private String id; private String name; private String fileName; private String url; @@ -14,8 +15,9 @@ public class Plugin implements Comparable<Plugin> { private boolean active; private List<String> dependencies; - public Plugin(String name, String fileName, String url, String version, long build, boolean active, + public PluginDescription(String id, String name, String fileName, String url, String version, long build, boolean active, List<String> dependencies) { + this.id = id; this.name = name; this.fileName = fileName; this.url = url; @@ -25,6 +27,10 @@ public class Plugin implements Comparable<Plugin> { this.dependencies = dependencies; } + public String getId() { + return id; + } + public String getName() { return name; } @@ -55,16 +61,16 @@ public class Plugin implements Comparable<Plugin> { @Override public boolean equals(Object obj) { - if (obj instanceof Plugin) { - Plugin p2 = (Plugin) obj; - return p2.active == active && p2.fileName.equals(fileName) && p2.name.equals(name) && p2.url.equals(url); + if (obj instanceof PluginDescription) { + PluginDescription p2 = (PluginDescription) obj; + return p2.active == active && p2.fileName.equals(fileName) && p2.id.equals(id) && p2.url.equals(url); } else { return super.equals(obj); } } @Override - public int compareTo(Plugin o) { + public int compareTo(PluginDescription o) { return getName().compareTo(o.getName()); } diff --git a/PlayWallCore/src/de/tobias/playpad/plugin/Plugins.java b/PlayWallCore/src/de/tobias/playpad/plugin/Plugins.java index 9cb3749a8f036e5f01a3cecb88c3a1e3eb5e577b..c01deacd4c44c4b35c14951581b06f384015b5e7 100644 --- a/PlayWallCore/src/de/tobias/playpad/plugin/Plugins.java +++ b/PlayWallCore/src/de/tobias/playpad/plugin/Plugins.java @@ -10,26 +10,28 @@ import java.util.List; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; public class Plugins { - private static List<Plugin> plugins; + private static List<PluginDescription> availablePlugins; static { - plugins = new ArrayList<>(); + availablePlugins = new ArrayList<>(); } - public static List<Plugin> load(String pluginInfoURL, boolean fetch) throws IOException { - if (plugins.isEmpty() || fetch) { - plugins.clear(); + public static List<PluginDescription> loadDescriptionFromServer(String pluginInfoURL, boolean fetch) throws IOException { + if (availablePlugins.isEmpty() || fetch) { + availablePlugins.clear(); URL url = new URL(pluginInfoURL); FileConfiguration cfg = YamlConfiguration.loadConfiguration(url.openStream()); // Iterate over all plugins that are online avialable for (String key : cfg.getConfigurationSection("plugins").getKeys(false)) { + String id = cfg.getString("plugins." + key + ".id"); String name = new String(cfg.getString("plugins." + key + ".name").getBytes(), "UTF-8"); String pluginUrl = cfg.getString("plugins." + key + ".url"); String fileName = cfg.getString("plugins." + key + ".filename"); @@ -44,14 +46,49 @@ public class Plugins { if (Files.exists(path)) active = true; - Plugin plugin = new Plugin(name, fileName, pluginUrl, version, build, active, dependencies); - plugins.add(plugin); + PluginDescription plugin = new PluginDescription(id, name, fileName, pluginUrl, version, build, active, dependencies); + availablePlugins.add(plugin); } } - return plugins; + return availablePlugins; + } + + public static List<PluginDescription> getAvailablePlugins() { + return availablePlugins; + } + + public static void loadDependencies(PluginDescription plugin) { + List<PluginDescription> dependencies = findDependencies(plugin); + dependencies.forEach(p -> + { + Path decPath = ApplicationUtils.getApplication().getPath(PathType.LIBRARY, p.getFileName()); + downloadPlugin(p, decPath); + + // Add Plugin to classpath + PlayPadPlugin.getImplementation().loadPlugin(decPath.toUri()); + }); } - public static List<Plugin> getPlugins() { + private static List<PluginDescription> findDependencies(PluginDescription plugin) { + List<PluginDescription> plugins = new ArrayList<>(); + for (String dependencyName : plugin.getDependencies()) { + for (PluginDescription desc : Plugins.getAvailablePlugins()) { + if (desc.getName().equals(dependencyName)) { + plugins.add(desc); + } + } + } return plugins; } + + public static void downloadPlugin(PluginDescription plugin, Path path) { + if (Files.notExists(path)) { + try { + Files.createDirectories(path.getParent()); + Files.copy(new URL(plugin.getUrl()).openStream(), path); + } catch (IOException e) { + e.printStackTrace(); + } + } + } } diff --git a/PlayWallCore/src/de/tobias/playpad/project/Project.java b/PlayWallCore/src/de/tobias/playpad/project/Project.java index f9ed58b8cf90b99fdff729996220fc5296a00b56..efa079db286bcad361e4d4b56e66bfcbd07465c1 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/Project.java +++ b/PlayWallCore/src/de/tobias/playpad/project/Project.java @@ -192,13 +192,15 @@ public class Project { public void save() throws IOException { Path projectPath = projectReference.getProjectPath(); - Document document = DocumentHelper.createDocument(); + // Modules clearen und beim Speichern der pads neu setzen, damit alte Modules, die nicht gebracht werden, entfernt werden können. + projectReference.getRequestedModules().clear(); + Document document = DocumentHelper.createDocument(); Element rootElement = document.addElement(ROOT_ELEMENT); // Speichern der Pads XMLHandler<Page> handler = new XMLHandler<>(rootElement); - handler.saveElements(PAGE_ELEMENT, pages.values(), new PageSerializer()); + handler.saveElements(PAGE_ELEMENT, pages.values(), new PageSerializer(this)); // Speichern der Settings Element settingsElement = rootElement.addElement(SETTINGS_ELEMENT); diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectExporter.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectExporter.java index 3fe6c2e24409a8cdf02e4868f4f62a9f8bcadc5d..74b5417b3604a080fe9ea6d8d7b6b12849c28951 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectExporter.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectExporter.java @@ -117,7 +117,7 @@ public class ProjectExporter { if (padObj instanceof Element) { Element padElement = (Element) padObj; - PadSerializer serializer = new PadSerializer(); + PadSerializer serializer = new PadSerializer(null); Pad pad = serializer.loadElement(padElement); if (pad.getContent() != null) { diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectImporter.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectImporter.java index 372fe52fa7301e6bee4163c1e38aabc5bd9e51ed..45eb65debe4a180059690fe9c1442788b2957963 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectImporter.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectImporter.java @@ -163,7 +163,7 @@ public class ProjectImporter { if (padObj instanceof Element) { Element padElement = (Element) padObj; - PadSerializer serializer = new PadSerializer(); + PadSerializer serializer = new PadSerializer(null); Pad pad = serializer.loadElement(padElement); if (pad.getContent() != null) { diff --git a/PlayWallCore/src/de/tobias/playpad/project/page/PageSerializer.java b/PlayWallCore/src/de/tobias/playpad/project/page/PageSerializer.java index 52807e5288b6c0fc60e4bfa3aff34cba3806f2e8..31b482bf2d35c862c8293892296ca33ac54d77ac 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/page/PageSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/project/page/PageSerializer.java @@ -18,12 +18,6 @@ public class PageSerializer implements XMLSerializer<Page>, XMLDeserializer<Page private Project project; - /** - * Für Serilize - */ - public PageSerializer() { - } - /** * Für Deserialize * @@ -57,6 +51,6 @@ public class PageSerializer implements XMLSerializer<Page>, XMLDeserializer<Page newElement.addAttribute(NAME_ATTR, data.getName()); XMLHandler<Pad> handler = new XMLHandler<>(newElement); - handler.saveElements(Project.PAD_ELEMENT, data.getPads(), new PadSerializer()); + handler.saveElements(Project.PAD_ELEMENT, data.getPads(), new PadSerializer(project)); } } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java index 84a48da72ee17c68881e98eedf22671af4846ccd..a99ef3740ec40f1bd4e3b06a184c70afb9536d01 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java @@ -6,7 +6,10 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.UUID; import org.dom4j.Document; @@ -15,6 +18,8 @@ import org.dom4j.DocumentHelper; import org.dom4j.Element; import de.tobias.playpad.Displayable; +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.plugin.Module; import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.ProfileReference; import de.tobias.utils.application.App; @@ -36,6 +41,7 @@ public class ProjectReference implements Displayable { private String name; private ProfileReference profileReference; + private Set<Module> requestedModules; private long size; private long lastMofied; @@ -46,6 +52,8 @@ public class ProjectReference implements Displayable { this.lastMofied = System.currentTimeMillis(); this.size = 0; this.profileReference = profileReference; + requestedModules = new HashSet<>(); + updateDisplayProperty(); } @@ -55,6 +63,20 @@ public class ProjectReference implements Displayable { this.size = size; this.lastMofied = lastMofied; this.profileReference = profileReference; + requestedModules = new HashSet<>(); + + updateDisplayProperty(); + } + + public ProjectReference(UUID uuid, String name, long size, long lastMofied, ProfileReference profileReference, + Set<Module> requestedModules) { + this.uuid = uuid; + this.name = name; + this.size = size; + this.lastMofied = lastMofied; + this.profileReference = profileReference; + this.requestedModules = requestedModules; + updateDisplayProperty(); } @@ -87,6 +109,26 @@ public class ProjectReference implements Displayable { updateDisplayProperty(); } + public Set<Module> getRequestedModules() { + return requestedModules; + } + + public void addRequestedModule(Module module) { + requestedModules.add(module); + } + + public Set<Module> getMissedModules() { + Set<Module> missedModules = new HashSet<>(); + Collection<Module> activeModules = PlayPadPlugin.getImplementation().getModules(); + for (Module requested : requestedModules) { + if (!activeModules.contains(requested)) { + missedModules.add(requested); + } + } + return missedModules; + } + + public ProfileReference getProfileReference() { return profileReference; } diff --git a/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java b/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java index cccd5a8f5e96f649a1d2d2bece319b86bbd0dccf..60d18c05feffe46d27f3e345fe1d1b3704415cd9 100644 --- a/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java +++ b/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java @@ -11,6 +11,8 @@ import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; +import de.tobias.playpad.plugin.Module; + /** * Eine Implementierung für eine Registry. * @@ -24,19 +26,22 @@ import org.dom4j.io.SAXReader; public class ComponentRegistry<C> implements Registry<C> { private HashMap<String, C> components; + private HashMap<String, Module> modules; private String name; public ComponentRegistry(String name) { - components = new HashMap<>(); + this.components = new HashMap<>(); + this.modules = new HashMap<>(); this.name = name; } @Override - public void registerComponent(C component, String id) throws IllegalArgumentException { + public void registerComponent(C component, String id, Module module) throws IllegalArgumentException { if (components.containsKey(id)) { throw new IllegalArgumentException("A components already exists with this id: " + id); } components.put(id, component); + modules.put(id, module); System.out.println("Registered: " + name + "#" + id); } @@ -59,7 +64,7 @@ public class ComponentRegistry<C> implements Registry<C> { } @Override - public void loadComponentsFromFile(URL url, ClassLoader loader) + public void loadComponentsFromFile(URL url, ClassLoader loader, Module module) throws IOException, DocumentException, ClassNotFoundException, InstantiationException, IllegalAccessException { if (url == null) { throw new IOException("URL not found: " + url); @@ -77,9 +82,13 @@ public class ComponentRegistry<C> implements Registry<C> { @SuppressWarnings("unchecked") Class<C> clazz = (Class<C>) loader.loadClass(element.getStringValue()); C component = clazz.newInstance(); - registerComponent(component, type); + registerComponent(component, type, module); } } } + @Override + public Module getModule(String id) { + return modules.get(id); + } } diff --git a/PlayWallCore/src/de/tobias/playpad/registry/DefaultComponentRegistry.java b/PlayWallCore/src/de/tobias/playpad/registry/DefaultComponentRegistry.java index f085a26114c6048cad549a7b17e7f7e1c6adeaed..a8b2dae1e98a084ff8401420129acbe109257393 100644 --- a/PlayWallCore/src/de/tobias/playpad/registry/DefaultComponentRegistry.java +++ b/PlayWallCore/src/de/tobias/playpad/registry/DefaultComponentRegistry.java @@ -8,6 +8,8 @@ import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; +import de.tobias.playpad.plugin.Module; + public class DefaultComponentRegistry<C> extends ComponentRegistry<C> implements DefaultRegistry<C> { private C defaultValue; @@ -46,7 +48,7 @@ public class DefaultComponentRegistry<C> extends ComponentRegistry<C> implements } @Override - public void loadComponentsFromFile(URL url, ClassLoader loader) + public void loadComponentsFromFile(URL url, ClassLoader loader, Module module) throws IOException, DocumentException, ClassNotFoundException, InstantiationException, IllegalAccessException { if (url == null) { throw new IOException("URL not found: " + url); @@ -64,7 +66,7 @@ public class DefaultComponentRegistry<C> extends ComponentRegistry<C> implements @SuppressWarnings("unchecked") Class<C> clazz = (Class<C>) loader.loadClass(element.getStringValue()); C component = clazz.newInstance(); - registerComponent(component, type); + registerComponent(component, type, module); if (element.attributeValue("default") != null) { String defaultValue = element.attributeValue("default"); diff --git a/PlayWallCore/src/de/tobias/playpad/registry/Registry.java b/PlayWallCore/src/de/tobias/playpad/registry/Registry.java index 74fe650f172da5b046918e653534dd56613ee6af..df4ff3af7f836393d50fc52817f84bdd4a5ed74c 100644 --- a/PlayWallCore/src/de/tobias/playpad/registry/Registry.java +++ b/PlayWallCore/src/de/tobias/playpad/registry/Registry.java @@ -3,6 +3,8 @@ package de.tobias.playpad.registry; import java.util.Collection; import java.util.Set; +import de.tobias.playpad.plugin.Module; + /** * Dieses Interface definiert Methoden bei Arbeit mit Komponenten, die durch Plugins zum Programm hinzugefügt werden können. * @@ -40,4 +42,13 @@ public interface Registry<C> extends WriteOnlyRegistry<C> { * @return Implementierungen */ public Collection<C> getComponents(); + + /** + * Gibt das Module zurück. + * + * @param id + * id der Komponente. + * @return Module + */ + public Module getModule(String id); } diff --git a/PlayWallCore/src/de/tobias/playpad/registry/WriteOnlyRegistry.java b/PlayWallCore/src/de/tobias/playpad/registry/WriteOnlyRegistry.java index 8a6f8859539d0734ff7b0899f973c38974a5a582..5326d6b212858937a49ef131323c9c63b4f0f847 100644 --- a/PlayWallCore/src/de/tobias/playpad/registry/WriteOnlyRegistry.java +++ b/PlayWallCore/src/de/tobias/playpad/registry/WriteOnlyRegistry.java @@ -5,6 +5,8 @@ import java.net.URL; import org.dom4j.DocumentException; +import de.tobias.playpad.plugin.Module; + /** * Eine Schnittstelle um Komponenten zu registrieren, aber nicht auszulesen. * @@ -24,10 +26,12 @@ public interface WriteOnlyRegistry<C> { * Komponente * @param id * ID + * @param module + * Module zu dem diese Komponente gehört * @throws IllegalArgumentException * Die Komponete gibt es bereits. */ - public void registerComponent(C component, String id) throws IllegalArgumentException; + public void registerComponent(C component, String id, Module module) throws IllegalArgumentException; /** * Lädt aus einer XML Datei die Komponenten Deklaration und registriert diese automatisch. @@ -36,6 +40,8 @@ public interface WriteOnlyRegistry<C> { * URL zur Deklaration * @param loader * ClassLoader + * @param module + * Module zu dem diese Komponente gehört * @throws IOException * Fehler beim Laden der Datei. * @throws DocumentException @@ -47,16 +53,16 @@ public interface WriteOnlyRegistry<C> { * @throws InstantiationException * Die Klasse konnte nicht instanziert werden */ - public void loadComponentsFromFile(URL url, ClassLoader loader) + public void loadComponentsFromFile(URL url, ClassLoader loader, Module module) throws IOException, DocumentException, ClassNotFoundException, InstantiationException, IllegalAccessException; - public default void loadComponentsFromFile(String name) + public default void loadComponentsFromFile(String name, Module module) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, DocumentException { - loadComponentsFromFile(getClass().getClassLoader().getResource(name), getClass().getClassLoader()); + loadComponentsFromFile(getClass().getClassLoader().getResource(name), getClass().getClassLoader(), module); } - public default void loadComponentsFromFile(String name, ClassLoader loader) + public default void loadComponentsFromFile(String name, ClassLoader loader, Module module) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException, DocumentException { - loadComponentsFromFile(loader.getResource(name), loader); + loadComponentsFromFile(loader.getResource(name), loader, module); } } diff --git a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java index 2516305ee7b7e610aa892aeb91666cbbbabcd942..d34f11b239f332a2ab712505bc35ca94779f6bde 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/Profile.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/Profile.java @@ -139,6 +139,8 @@ public class Profile { } public void save() throws UnsupportedEncodingException, IOException { + ref.getRequestedModules().clear(); + PlayPadPlugin.getImplementation().getSettingsListener().forEach(l -> { try { diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java index 5da855184620b09850f69206abe6eff4473eb140..24bb8f34311c9d92f944e7a4c089f676be2e62bd 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java @@ -5,7 +5,9 @@ import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.UUID; import org.dom4j.Document; @@ -14,6 +16,7 @@ import org.dom4j.DocumentHelper; import org.dom4j.Element; import de.tobias.playpad.Displayable; +import de.tobias.playpad.plugin.Module; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; import de.tobias.utils.util.FileUtils; @@ -36,6 +39,7 @@ public class ProfileReference implements Displayable { private final UUID uuid; private String name; + private Set<Module> requestedModules; /** * Erstellt eine neue Referenz mit einer Random UUID. @@ -46,6 +50,7 @@ public class ProfileReference implements Displayable { public ProfileReference(String name) { this.name = name; this.uuid = UUID.randomUUID(); + requestedModules = new HashSet<>(); updateDisplayProperty(); } @@ -63,6 +68,19 @@ public class ProfileReference implements Displayable { updateDisplayProperty(); } + /** + * Erstellt eine neue Referenz mit Namen und UUID. + * + * @param uuid + * UUID + * @param name + * Name + */ + public ProfileReference(UUID uuid, String name, Set<Module> requestedModules) { + this(uuid, name); + this.requestedModules = requestedModules; + } + /** * Gibt den Namen zurück * @@ -91,6 +109,15 @@ public class ProfileReference implements Displayable { this.name = name; updateDisplayProperty(); } + + + public Set<Module> getRequestedModules() { + return requestedModules; + } + + public void addRequestedModule(Module module) { + requestedModules.add(module); + } // Verwaltungsmethoden für Profile Referenzen // TODO Extract in Extra Class diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileReferenceSerializer.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileReferenceSerializer.java index 19915d809824b0308575ec18ea31ccc0eab51067..b1c1fa689c7425647727a5fa7dc1a9c5fb1bb18d 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/ProfileReferenceSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/ProfileReferenceSerializer.java @@ -1,10 +1,15 @@ package de.tobias.playpad.settings; +import java.util.HashSet; +import java.util.Set; import java.util.UUID; import org.dom4j.Element; +import de.tobias.playpad.plugin.Module; +import de.tobias.playpad.plugin.ModuleSerializer; import de.tobias.utils.xml.XMLDeserializer; +import de.tobias.utils.xml.XMLHandler; import de.tobias.utils.xml.XMLSerializer; /** @@ -19,13 +24,17 @@ public class ProfileReferenceSerializer implements XMLSerializer<ProfileReferenc private static final String UUID_ATTR = "uuid"; private static final String NAME_ATTR = "name"; + private static final String MODULE_ELEMENT = "Module"; @Override public ProfileReference loadElement(Element element) { UUID uuid = UUID.fromString(element.attributeValue(UUID_ATTR)); String name = element.attributeValue(NAME_ATTR); - ProfileReference ref = new ProfileReference(uuid, name); + XMLHandler<Module> handler = new XMLHandler<>(element); + Set<Module> modules = new HashSet<>(handler.loadElements(MODULE_ELEMENT, new ModuleSerializer())); + + ProfileReference ref = new ProfileReference(uuid, name, modules); return ref; } @@ -33,6 +42,9 @@ public class ProfileReferenceSerializer implements XMLSerializer<ProfileReferenc public void saveElement(Element newElement, ProfileReference data) { newElement.addAttribute(UUID_ATTR, data.getUuid().toString()); newElement.addAttribute(NAME_ATTR, data.getName()); + + XMLHandler<Module> handler = new XMLHandler<>(newElement); + handler.saveElements(MODULE_ELEMENT, data.getRequestedModules(), new ModuleSerializer()); } } diff --git a/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java b/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java index 9b2274c4c31ced8afdd4342024a88c6ea83d5083..8dfa58c1a3affc3f217f5d22e6b9af2a19a4ba6c 100644 --- a/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java +++ b/PlayWallCore/src/de/tobias/playpad/update/UpdateRegistery.java @@ -3,8 +3,8 @@ package de.tobias.playpad.update; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; -import java.util.ArrayList; -import java.util.List; +import java.util.HashSet; +import java.util.Set; import de.tobias.utils.util.OS; import de.tobias.utils.util.SystemUtils; @@ -14,18 +14,18 @@ import net.minidev.json.JSONStyle; public class UpdateRegistery { - private static List<Updatable> updatables = new ArrayList<>(); - private static List<Updatable> availableUpdates = new ArrayList<>(); + private static Set<Updatable> updatables = new HashSet<>(); + private static Set<Updatable> availableUpdates = new HashSet<>(); public static void registerUpdateable(Updatable updatable) { updatables.add(updatable); } - public static List<Updatable> getAvailableUpdates() { + public static Set<Updatable> getAvailableUpdates() { return availableUpdates; } - public static List<Updatable> lookupUpdates(UpdateChannel channel) { + public static Set<Updatable> lookupUpdates(UpdateChannel channel) { availableUpdates.clear(); for (Updatable updatable : UpdateRegistery.updatables) { try { diff --git a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/ActionsPlugin.java b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/ActionsPlugin.java index 13aec012801daff5a9206c7ec8ed05d980b0e042..0a063bd8592dff1f43a1cebe95536392fe966cdd 100644 --- a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/ActionsPlugin.java +++ b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/ActionsPlugin.java @@ -1,7 +1,7 @@ package de.tobias.playpad.actionsplugin; -import net.xeoh.plugins.base.Plugin; +import de.tobias.playpad.plugin.AdvancedPlugin; -public interface ActionsPlugin extends Plugin { +public interface ActionsPlugin extends AdvancedPlugin { } diff --git a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java index e698c26478e0e502356409b33536c839ee0a7948..31b62316d5510e01b49c088868b1a26f6edbac14 100644 --- a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java +++ b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java @@ -9,11 +9,12 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.action.ActionConnect; import de.tobias.playpad.actionsplugin.ActionsPlugin; +import de.tobias.playpad.plugin.Module; 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; +import de.tobias.playpad.update.Updatable; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.ui.HUD; import de.tobias.utils.ui.icon.FontIcon; @@ -35,6 +36,12 @@ import net.xeoh.plugins.base.annotations.events.Shutdown; @PluginImplementation public class ActionsPluginImpl implements ActionsPlugin, ChangeListener<Boolean>, ProfileListener { + private static final String NAME = "ActionsPlugin"; + private static final String IDENTIFIER = "de.tobias.playpad.actions.impl.ActionsPluginImpl"; + + private static Module module; + private static ActionsPluginUpdater updater; + private static ResourceBundle bundle; public static CheckMenuItem muteMenuItem; @@ -100,12 +107,13 @@ public class ActionsPluginImpl implements ActionsPlugin, ChangeListener<Boolean> }; } - UpdateRegistery.registerUpdateable(new ActionsPluginUpdater()); Profile.registerListener(this); + module = new Module(NAME, IDENTIFIER); + updater = new ActionsPluginUpdater(); try { Registry<ActionConnect> padContents = PlayPadPlugin.getRegistryCollection().getActions(); - padContents.loadComponentsFromFile("de/tobias/playpad/actionsplugin/assets/Actions.xml", getClass().getClassLoader()); + padContents.loadComponentsFromFile("de/tobias/playpad/actionsplugin/assets/Actions.xml", getClass().getClassLoader(), module); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | DocumentException e) { e.printStackTrace(); } @@ -162,4 +170,14 @@ public class ActionsPluginImpl implements ActionsPlugin, ChangeListener<Boolean> } }); } + + @Override + public Module getModule() { + return module; + } + + @Override + public Updatable getUpdatable() { + return updater; + } } diff --git a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/AwakePlugin.java b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/AwakePlugin.java index abda3de1f2a37514e3f7180328e2f2fc3ca0adb2..fe0c9a54f1ce2eb82593e3011ee54cada9eeaf94 100644 --- a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/AwakePlugin.java +++ b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/AwakePlugin.java @@ -1,7 +1,7 @@ package de.tobias.playpad.awakeplugin; -import net.xeoh.plugins.base.Plugin; +import de.tobias.playpad.plugin.AdvancedPlugin; -public interface AwakePlugin extends Plugin { +public interface AwakePlugin extends AdvancedPlugin { } diff --git a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java index ead13c66e180a23982c29bc06f9354e0d6fd2059..fdff1898e44fa986830126cbfa55e44bbd669290 100644 --- a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java +++ b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java @@ -12,10 +12,11 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.awakeplugin.AwakePlugin; import de.tobias.playpad.awakeplugin.AwakeSettings; +import de.tobias.playpad.plugin.Module; 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.update.Updatable; import de.tobias.playpad.view.main.MenuType; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; @@ -40,6 +41,12 @@ import net.xeoh.plugins.base.annotations.events.Shutdown; @PluginImplementation public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewController>, EventHandler<ActionEvent>, SettingsListener { + private static final String NAME = "AwakePlugin"; + private static final String IDENTIFIER = "de.tobias.playpad.awakeplugin.impl.AwakePluginImpl"; + + private Module module; + private Updatable updatable; + private static final String SETTINGS_FILENAME = "Awake.xml"; private CheckMenuItem activeMenu; @@ -53,7 +60,8 @@ public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewCon public void onLoad(AwakePlugin plugin) { bundle = Localization.loadBundle("de/tobias/playpad/awakeplugin/assets/awake", getClass().getClassLoader()); - UpdateRegistery.registerUpdateable(new AwakePluginUpdater()); + module = new Module(NAME, IDENTIFIER); + updatable = new AwakePluginUpdater(); if (OS.getType() == OSType.Windows) { try { @@ -120,7 +128,7 @@ public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewCon try { settings = AwakeSettings.load(path); } catch (NoSuchFileException e) { - System.out.println("No Awake.xml config on folder"); + System.out.println("No Awake.xml config in folder"); } catch (DocumentException | IOException e) { e.printStackTrace(); } @@ -181,7 +189,7 @@ public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewCon } } - public void activeSleep(boolean activate) { + private void activeSleep(boolean activate) { if (activate) { if (OS.getType() == OSType.Windows) { Kernel32.INSTANCE.SetThreadExecutionState(Kernel32.ES_CONTINUOUS | Kernel32.ES_DISPLAY_REQUIRED | Kernel32.ES_SYSTEM_REQUIRED); @@ -196,4 +204,14 @@ public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewCon } } } + + @Override + public Module getModule() { + return module; + } + + @Override + public Updatable getUpdatable() { + return updatable; + } } diff --git a/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/EqualizerPlugin.java b/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/EqualizerPlugin.java index 93b16f1acdd36bc81219fabae3c646090bf5b386..7bac7c99575712af4df4987be1ae337b4c3df8ed 100644 --- a/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/EqualizerPlugin.java +++ b/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/EqualizerPlugin.java @@ -1,8 +1,7 @@ package de.tobias.playpad.equalizerplugin.main; -import net.xeoh.plugins.base.Plugin; +import de.tobias.playpad.plugin.AdvancedPlugin; - -public interface EqualizerPlugin extends Plugin { +public interface EqualizerPlugin extends AdvancedPlugin { } 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 92c5255726809d7b30ee09b4158ccfcdaa2ce47f..afdd5cba281c43519ae2fb111f0315a739548944 100644 --- a/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java +++ b/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java @@ -11,9 +11,10 @@ import de.tobias.playpad.equalizerplugin.main.Equalizer; import de.tobias.playpad.equalizerplugin.main.EqualizerPlugin; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.conntent.PadContent; +import de.tobias.playpad.plugin.Module; import de.tobias.playpad.plugin.PadListener; import de.tobias.playpad.plugin.WindowListener; -import de.tobias.playpad.update.UpdateRegistery; +import de.tobias.playpad.update.Updatable; import de.tobias.playpad.view.main.MenuType; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.application.ApplicationUtils; @@ -33,6 +34,12 @@ import net.xeoh.plugins.base.annotations.events.Shutdown; @PluginImplementation public class EqualizerPluginImpl implements EqualizerPlugin, WindowListener<IMainViewController>, EventHandler<ActionEvent>, PadListener { + private static final String NAME = "Equalizer"; + private static final String IDENTIFIER = "de.tobias.playpad.videoplugin.main.impl.EqualizerPluginImpl"; + + private Module module; + private Updatable updatable; + private Stage mainStage; private EqualizerViewController equalizerViewController; private static ResourceBundle bundle; @@ -52,7 +59,8 @@ public class EqualizerPluginImpl implements EqualizerPlugin, WindowListener<IMai e.printStackTrace(); } - UpdateRegistery.registerUpdateable(new EqualizerPluginUpdater()); + updatable = new EqualizerPluginUpdater(); + module = new Module(NAME, IDENTIFIER); PlayPadPlugin.getImplementation().addMainViewListener(this); PlayPadPlugin.getImplementation().addPadListener(this); @@ -126,4 +134,14 @@ public class EqualizerPluginImpl implements EqualizerPlugin, WindowListener<IMai equalizerViewController.getStage().show(); } } + + @Override + public Module getModule() { + return module; + } + + @Override + public Updatable getUpdatable() { + return updatable; + } } \ No newline at end of file diff --git a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/LaunchpadPlugin.java b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/LaunchpadPlugin.java index 1508fc74c06a2e3892c4bb90150670da800e2713..f3b49ca01f45b03ea7e562a6bbcf0b59240081d7 100644 --- a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/LaunchpadPlugin.java +++ b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/LaunchpadPlugin.java @@ -1,7 +1,7 @@ package de.tobias.playpad.launchpadplugin; -import net.xeoh.plugins.base.Plugin; +import de.tobias.playpad.plugin.AdvancedPlugin; -public interface LaunchpadPlugin extends Plugin { +public interface LaunchpadPlugin extends AdvancedPlugin { } diff --git a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/impl/LaunchpadPluginImpl.java b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/impl/LaunchpadPluginImpl.java index fabff9d69c470b5bb7a76feffae9889d44c91606..d3ebeffe2c87843472bcaac9aa4920488e5a5371 100644 --- a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/impl/LaunchpadPluginImpl.java +++ b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/impl/LaunchpadPluginImpl.java @@ -6,7 +6,8 @@ import de.tobias.playpad.launchpadplugin.LaunchpadPlugin; import de.tobias.playpad.launchpadplugin.midi.device.mk2.LaunchPadMK2; import de.tobias.playpad.launchpadplugin.midi.device.s.LaunchPadS; import de.tobias.playpad.midi.device.DeviceRegistry; -import de.tobias.playpad.update.UpdateRegistery; +import de.tobias.playpad.plugin.Module; +import de.tobias.playpad.update.Updatable; import de.tobias.utils.util.Localization; import net.xeoh.plugins.base.annotations.PluginImplementation; import net.xeoh.plugins.base.annotations.events.PluginLoaded; @@ -15,18 +16,23 @@ import net.xeoh.plugins.base.annotations.events.Shutdown; @PluginImplementation public class LaunchpadPluginImpl implements LaunchpadPlugin { + private static final String NAME = "LaunchPadPlugin"; + private static final String IDENTIFIER = "de.tobias.playpad.launchpadplugin.impl.LaunchpadPluginImpl"; + private static ResourceBundle bundle; + private LaunchPadPluginUpdater updater; + private Module module; @PluginLoaded public void onLoaded(LaunchpadPlugin plugin) { bundle = Localization.loadBundle("de/tobias/playpad/launchpadplugin/assets/launchpad", LaunchpadPluginImpl.class.getClassLoader()); - - UpdateRegistery.registerUpdateable(new LaunchPadPluginUpdater()); + updater = new LaunchPadPluginUpdater(); + module = new Module(NAME, IDENTIFIER); DeviceRegistry deviceFactory = DeviceRegistry.getFactoryInstance(); - deviceFactory.registerDevice(LaunchPadMK2.NAME, LaunchPadMK2.class); deviceFactory.registerDevice(LaunchPadS.NAME, LaunchPadS.class); + System.out.println("Enable LaunchPad Plugin"); } @@ -39,4 +45,13 @@ public class LaunchpadPluginImpl implements LaunchpadPlugin { return bundle; } + @Override + public Module getModule() { + return module; + } + + @Override + public Updatable getUpdatable() { + return updater; + } } diff --git a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/mk2/LaunchPadMK2.java b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/mk2/LaunchPadMK2.java index 01a33d47e0a9d1dde2fe6c4e5f2e69faebf200d5..389b2ab772f3d47d0d62e3f20cf0ba05cfead83e 100644 --- a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/mk2/LaunchPadMK2.java +++ b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/mk2/LaunchPadMK2.java @@ -19,6 +19,8 @@ import javafx.scene.paint.Color; public class LaunchPadMK2 extends Device implements DeviceColorAssociatorConnector { public static final String NAME = "Launchpad MK2"; + + // Modern Colors mapped to the colors of the launchpad private static Map<String, String> mapProperties; public LaunchPadMK2() { @@ -41,7 +43,8 @@ public class LaunchPadMK2 extends Device implements DeviceColorAssociatorConnect } @Override - public void initFeedback() {} + public void initDevice() { + } @Override public void handleFeedback(FeedbackMessage type, int key, Feedback feedback) { @@ -114,14 +117,16 @@ public class LaunchPadMK2 extends Device implements DeviceColorAssociatorConnect @Override public DisplayableFeedbackColor map(Color color) { - try { - URL resource = getClass().getClassLoader().getResource("de/tobias/playpad/launchpadplugin/assets/launchpad_mk2.map"); - mapProperties = MapParser.load(resource); - } catch (Exception e) { - e.printStackTrace(); - } + // TEST Ist das nötig + // try { + // URL resource = getClass().getClassLoader().getResource("de/tobias/playpad/launchpadplugin/assets/launchpad_mk2.map"); + // mapProperties = MapParser.load(resource); + // } catch (Exception e) { + // e.printStackTrace(); + // } if (mapProperties.containsKey(color.toString())) { - return LaunchPadMK2Color.valueOf(mapProperties.get(color.toString())); + String nameOfConst = mapProperties.get(color.toString()); + return LaunchPadMK2Color.valueOf(nameOfConst); } return null; } diff --git a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/s/LaunchPadS.java b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/s/LaunchPadS.java index 64b9651e27d0de4f83858259eec37c8a2ed7a902..693d49e063b5beac6f5b8565ffbbc1e19875d03f 100644 --- a/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/s/LaunchPadS.java +++ b/PlayWallPlugins/launchpadplugin/de/tobias/playpad/launchpadplugin/midi/device/s/LaunchPadS.java @@ -26,7 +26,7 @@ public class LaunchPadS extends Device implements DeviceColorAssociatorConnector } @Override - public void initFeedback() { + public void initDevice() { // Flash Enable try { Midi.getInstance().sendMessage(176, 0, 40); @@ -37,7 +37,7 @@ public class LaunchPadS extends Device implements DeviceColorAssociatorConnector @Override public void handleFeedback(FeedbackMessage type, int key, Feedback feedback) { - initFeedback(); + initDevice(); int command = 144; diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/MediaPlugin.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/MediaPlugin.java new file mode 100644 index 0000000000000000000000000000000000000000..13771b03fc38d046adfb1b2b25a96ad9ee9474da --- /dev/null +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/MediaPlugin.java @@ -0,0 +1,8 @@ +package de.tobias.playpad.mediaplugin.main; + +import de.tobias.playpad.plugin.AdvancedPlugin; + + +public interface MediaPlugin extends AdvancedPlugin { + +} diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/VideoPlugin.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/VideoPlugin.java deleted file mode 100644 index 715650a73a239e4c1a948a52e363958577b22f1f..0000000000000000000000000000000000000000 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/VideoPlugin.java +++ /dev/null @@ -1,8 +0,0 @@ -package de.tobias.playpad.mediaplugin.main; - -import net.xeoh.plugins.base.Plugin; - - -public interface VideoPlugin extends Plugin { - -} 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 7b71b3255ffa67ac72acbcee2bd858ecb636e47e..7aae50323fa1dac3be752697e17fce6e2878ddb4 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaPluginImpl.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaPluginImpl.java @@ -9,13 +9,14 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.action.ActionConnect; -import de.tobias.playpad.mediaplugin.main.VideoPlugin; +import de.tobias.playpad.mediaplugin.main.MediaPlugin; import de.tobias.playpad.mediaplugin.main.VideoSettings; import de.tobias.playpad.pad.conntent.PadContentConnect; +import de.tobias.playpad.plugin.Module; import de.tobias.playpad.plugin.SettingsListener; import de.tobias.playpad.registry.Registry; import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.update.UpdateRegistery; +import de.tobias.playpad.update.Updatable; import de.tobias.utils.ui.HUD; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -33,8 +34,14 @@ import net.xeoh.plugins.base.annotations.events.PluginLoaded; import net.xeoh.plugins.base.annotations.events.Shutdown; @PluginImplementation -public class MediaPluginImpl implements VideoPlugin, SettingsListener, ChangeListener<Boolean> { +public class MediaPluginImpl implements MediaPlugin, SettingsListener, ChangeListener<Boolean> { + private static final String NAME = "MediaPlugin"; + private static final String IDENTIFIER = "de.tobias.playpad.videoplugin.main.impl.VideoPluginImpl"; + + private static Module module; + private static MediaPluginUpdater updater; + private static MediaPluginImpl instance; private MediaViewController videoViewController; private VideoSettings settings = new VideoSettings(); @@ -46,8 +53,12 @@ public class MediaPluginImpl implements VideoPlugin, SettingsListener, ChangeLis private static final String SETTINGS_FILENAME = "Media.xml"; @PluginLoaded - public void onEnable(VideoPlugin plugin) { + public void onEnable(MediaPlugin plugin) { + // Init instance = this; + updater = new MediaPluginUpdater(); + module = new Module(NAME, IDENTIFIER); + blindProperty = new SimpleBooleanProperty(); bundle = Localization.loadBundle("de/tobias/playpad/mediaplugin/assets/video", getClass().getClassLoader()); @@ -56,7 +67,7 @@ public class MediaPluginImpl implements VideoPlugin, SettingsListener, ChangeLis // Load Content Types try { Registry<PadContentConnect> padContents = PlayPadPlugin.getRegistryCollection().getPadContents(); - padContents.loadComponentsFromFile("de/tobias/playpad/mediaplugin/assets/PadContent.xml", getClass().getClassLoader()); + padContents.loadComponentsFromFile("de/tobias/playpad/mediaplugin/assets/PadContent.xml", getClass().getClassLoader(), module); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | DocumentException e) { e.printStackTrace(); } @@ -83,11 +94,9 @@ public class MediaPluginImpl implements VideoPlugin, SettingsListener, ChangeLis }); } - UpdateRegistery.registerUpdateable(new MediaPluginUpdater()); - try { Registry<ActionConnect> padContents = PlayPadPlugin.getRegistryCollection().getActions(); - padContents.loadComponentsFromFile("de/tobias/playpad/mediaplugin/assets/Actions.xml", getClass().getClassLoader()); + padContents.loadComponentsFromFile("de/tobias/playpad/mediaplugin/assets/Actions.xml", getClass().getClassLoader(), module); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | DocumentException e) { e.printStackTrace(); } @@ -161,4 +170,14 @@ public class MediaPluginImpl implements VideoPlugin, SettingsListener, ChangeLis } }); } + + @Override + public Module getModule() { + return module; + } + + @Override + public Updatable getUpdatable() { + return updater; + } }