diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java index 87f7d7a857d90cc61da1639b9dd7bcab56e68b28..b623ca151241ecef1191577afd2aec20aad0b0b3 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java @@ -210,6 +210,7 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { content.save(contentElement); Module module = PlayPadPlugin.getRegistryCollection().getPadContents().getModule(content.getType()); + // Für verschiedene Pad Typen wird hier das Modul gespeichert, damit das Projekt weis, welche notwendig sien beim öffnen project.getProjectReference().addRequestedModule(module); } } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java index a99ef3740ec40f1bd4e3b06a184c70afb9536d01..c83804a93569a3d65b62ca3a9cdef2188e3fc165 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java @@ -43,24 +43,31 @@ public class ProjectReference implements Displayable { private ProfileReference profileReference; private Set<Module> requestedModules; - private long size; private long lastMofied; public ProjectReference(UUID uuid, String name, ProfileReference profileReference) { this.uuid = uuid; this.name = name; this.lastMofied = System.currentTimeMillis(); - this.size = 0; this.profileReference = profileReference; requestedModules = new HashSet<>(); updateDisplayProperty(); } - public ProjectReference(UUID uuid, String name, long size, long lastMofied, ProfileReference profileReference) { + public ProjectReference(UUID uuid, String name, ProfileReference profileReference, Set<Module> modules) { + this.uuid = uuid; + this.name = name; + this.lastMofied = System.currentTimeMillis(); + this.profileReference = profileReference; + requestedModules = modules; + + updateDisplayProperty(); + } + + public ProjectReference(UUID uuid, String name, long lastMofied, ProfileReference profileReference) { this.uuid = uuid; this.name = name; - this.size = size; this.lastMofied = lastMofied; this.profileReference = profileReference; requestedModules = new HashSet<>(); @@ -68,11 +75,9 @@ public class ProjectReference implements Displayable { updateDisplayProperty(); } - public ProjectReference(UUID uuid, String name, long size, long lastMofied, ProfileReference profileReference, - Set<Module> requestedModules) { + public ProjectReference(UUID uuid, String name, 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; @@ -88,14 +93,6 @@ public class ProjectReference implements Displayable { return name; } - public long getSize() { - return size; - } - - public void setSize(long size) { - this.size = size; - } - public void setLastMofied(long lastMofied) { this.lastMofied = lastMofied; } @@ -112,11 +109,11 @@ public class ProjectReference implements Displayable { 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(); @@ -125,10 +122,15 @@ public class ProjectReference implements Displayable { missedModules.add(requested); } } + + for (Module requested : profileReference.getRequestedModules()) { + if (!activeModules.contains(requested)) { + missedModules.add(requested); + } + } return missedModules; } - public ProfileReference getProfileReference() { return profileReference; } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java index 3d6996db4d8f5fc1a73a8da8a1cf446a3b267897..4c92383e76f577f22ea9f7921f83cabc08954940 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java @@ -3,14 +3,19 @@ package de.tobias.playpad.project.ref; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +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.playpad.settings.ProfileReference; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; import de.tobias.utils.xml.XMLDeserializer; +import de.tobias.utils.xml.XMLHandler; import de.tobias.utils.xml.XMLSerializer; public class ProjectReferenceSerializer implements XMLDeserializer<ProjectReference>, XMLSerializer<ProjectReference> { @@ -18,6 +23,7 @@ public class ProjectReferenceSerializer implements XMLDeserializer<ProjectRefere private static final String UUID_ATTR = "uuid"; private static final String NAME_ATTR = "name"; private static final String PROFILE_ATTR = "profile"; + private static final String MODULE_ELEMENT = "Module"; @Override public ProjectReference loadElement(Element element) { @@ -25,14 +31,16 @@ public class ProjectReferenceSerializer implements XMLDeserializer<ProjectRefere String name = element.attributeValue(NAME_ATTR); UUID profile = UUID.fromString(element.attributeValue(PROFILE_ATTR)); + XMLHandler<Module> handler = new XMLHandler<>(element); + Set<Module> modules = new HashSet<>(handler.loadElements(MODULE_ELEMENT, new ModuleSerializer())); + ProfileReference profileRef = ProfileReference.getReference(profile); - ProjectReference ref = new ProjectReference(uuid, name, profileRef); + ProjectReference ref = new ProjectReference(uuid, name, profileRef, modules); Path projectPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, ref.getFileName()); if (Files.exists(projectPath)) { try { ref.setLastMofied(Files.getLastModifiedTime(projectPath).toMillis()); - ref.setSize(Files.size(projectPath)); } catch (IOException e) { e.printStackTrace(); } @@ -45,5 +53,8 @@ public class ProjectReferenceSerializer implements XMLDeserializer<ProjectRefere newElement.addAttribute(UUID_ATTR, data.getUuid().toString()); newElement.addAttribute(NAME_ATTR, data.getName()); newElement.addAttribute(PROFILE_ATTR, data.getProfileReference().getUuid().toString()); + + XMLHandler<Module> handler = new XMLHandler<>(newElement); + handler.saveElements(MODULE_ELEMENT, data.getRequestedModules(), new ModuleSerializer()); } } diff --git a/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java b/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java index 60d18c05feffe46d27f3e345fe1d1b3704415cd9..d5e4d04a52bc1e667d14096be4a7bb58696fa7dd 100644 --- a/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java +++ b/PlayWallCore/src/de/tobias/playpad/registry/ComponentRegistry.java @@ -26,6 +26,7 @@ import de.tobias.playpad.plugin.Module; public class ComponentRegistry<C> implements Registry<C> { private HashMap<String, C> components; + // Zu einem Component die zugehörigen Meta Daten (das Modul) private HashMap<String, Module> modules; private String name;