diff --git a/.idea/ant.xml b/.idea/ant.xml deleted file mode 100644 index 9ec298f22d3ea3a74fba0ee285c8b69f9aad243f..0000000000000000000000000000000000000000 --- a/.idea/ant.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="AntConfiguration"> - <buildFile url="file://$PROJECT_DIR$/PlayWall/build.xml" /> - </component> -</project> \ No newline at end of file diff --git a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/cell/path/PathMatchPathCell.java b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/cell/path/PathMatchPathCell.java index 1b8eeec9e8012f5f6e3827536301668f2fe3a70e..b7617a56064b2287cc7c3fa2eeb6496544512004 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/cell/path/PathMatchPathCell.java +++ b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/cell/path/PathMatchPathCell.java @@ -4,6 +4,8 @@ import de.tobias.playpad.view.PseudoClasses; import de.tobias.playpad.viewcontroller.dialog.PathMatchDialog; import javafx.scene.control.TableCell; +import java.nio.file.Path; + public class PathMatchPathCell extends TableCell<PathMatchDialog.TempMediaPath, PathMatchDialog.TempMediaPath> { @Override @@ -14,7 +16,10 @@ public class PathMatchPathCell extends TableCell<PathMatchDialog.TempMediaPath, if (item.isMatched()) { setText(item.getLocalPath().toString()); } else { - setText(item.getMediaPath().getPath().toString()); + Path path = item.getMediaPath().getPath(); + if (path != null) { + setText(path.toString()); + } } } else { setText(null); diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/Pad.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/Pad.java index 813e6792449f2015766119784717aa08b7ca7e04..2a0fd4c28cda491ab99634c36b4f2ac2ac967598 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/Pad.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/Pad.java @@ -365,7 +365,10 @@ public class Pad { public void removePath(MediaPath path) { mediaPaths.remove(path); + } + + public void removePathListener(MediaPath path) { if (project.getProjectReference().isSync()) { CommandManager.execute(Commands.PATH_REMOVE, project.getProjectReference(), path); } diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/project/importer/ProjectImporter.java b/PlayWallCore/src/main/java/de/tobias/playpad/project/importer/ProjectImporter.java index 9efe6faaf3f59492e073eed7a4d39eeb440c5c2e..929439321f5774dd3bec635ffc13d37c5e7c155a 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/project/importer/ProjectImporter.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/project/importer/ProjectImporter.java @@ -26,10 +26,7 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.UUID; +import java.util.*; /** * Created by tobias on 11.03.17. @@ -69,10 +66,11 @@ public class ProjectImporter { } importedProjectReference = importProjectFile(); - replaceMediaPathIds(loadMediaPaths()); if (includeMedia && delegate.shouldImportMedia()) { - importMedia(); + importMedia(loadMediaPaths()); + } else { + replaceMediaPathIds(loadMediaPaths()); } } @@ -146,10 +144,20 @@ public class ProjectImporter { Project project = loader.load(); for (Pad pad : project.getPads()) { - pad.getPaths().forEach(oldMediaPath -> find(mediaPaths, oldMediaPath.getId()).ifPresent(result -> { - pad.removePath(oldMediaPath); - pad.setPath(result.getPath()); - })); + Iterator<MediaPath> iterator = pad.getPaths().iterator(); + while (iterator.hasNext()) { + MediaPath oldMediaPath = iterator.next(); + find(mediaPaths, oldMediaPath.getId()).ifPresent(result -> { + try { + pad.removePathListener(oldMediaPath); + iterator.remove(); + + pad.setPath(result.getPath()); + } catch (NullPointerException e) { + Logger.error("Import Error on Pad: " + pad.getUuid()); + } + }); + } } } @@ -202,7 +210,7 @@ public class ProjectImporter { profileUUID = localProfileUUID; // Update Profile UUID with new local profile uuid } - private void importMedia() throws ProjectNotFoundException, ProfileNotFoundException, DocumentException, + private void importMedia(List<MediaPath> mediaPaths) throws ProjectNotFoundException, ProfileNotFoundException, DocumentException, IOException, ProfileAbortException { Path folder = delegate.getMediaPath(); @@ -212,12 +220,16 @@ public class ProjectImporter { for (Pad pad : project.getPads()) { for (MediaPath path : pad.getPaths()) { - Path fileName = path.getPath().getFileName(); - Path zipMediaFile = Paths.get("/media").resolve(fileName); - Path newMediaPath = folder.resolve(fileName); + Optional<MediaPath> result = find(mediaPaths, path.getId()); + + if (result.isPresent()) { + String fileName = result.get().getFileName(); + Path zipMediaFile = Paths.get("/media").resolve(fileName); + Path newMediaPath = folder.resolve(fileName); - zip.getFile(zipMediaFile, newMediaPath); - path.setPath(newMediaPath, false); + zip.getFile(zipMediaFile, newMediaPath); + path.setPath(newMediaPath, false); + } } } ProjectReferenceManager.saveSingleProject(project);