diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index e1f9e1b3a867b0b3749e3d6989f31d801b0d7e64..f7d817b5155e611268fe95e7f1049a01f5e35969 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -483,7 +483,6 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro projectSettingsViewController = null; mainStage.toFront(); - System.out.println("Done"); }; projectSettingsViewController = new ProjectSettingsViewController(mainViewController.getScreen(), mainStage, currentProject, diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java index 0ae505cfe09061350771520d7228e40f05bd9f70..0f6ebcf06fa4822a2e58e41a4fa87f9091b004e5 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java @@ -1,6 +1,7 @@ package de.tobias.playpad.layout.desktop; import java.io.File; +import java.io.IOException; import java.nio.file.Path; import java.util.Set; @@ -67,7 +68,8 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand padDurationListener = new PadDurationListener(this); padPositionListener = new PadPositionListener(this); - // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController erzeugt + // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController + // erzeugt ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); profileSettings.lockedProperty().addListener(padLockedListener); } @@ -244,7 +246,7 @@ public class DesktopPadViewController implements IPadViewControllerV2, EventHand try { content.handlePath(file.toPath()); - } catch (NoSuchComponentException e) { + } catch (NoSuchComponentException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java index f9fc5e94ad102fa570dab5350a4af038004894ff..5983e6d5c7086995533cd2fe33a81feccf60935d 100644 --- a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java +++ b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java @@ -1,6 +1,7 @@ package de.tobias.playpad.pad.content; import java.io.FileNotFoundException; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -69,11 +70,11 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, } @Override - public void handlePath(Path path) throws NoSuchComponentException { + public void handlePath(Path path) throws NoSuchComponentException, IOException { // handle old media unloadMedia(); - this.path = path; + this.path = getRealPath(path); // handle new media loadMedia(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java index 354e1157394325d3f6d074db7caa417f796a527a..e857d85a4b8fce9d403f043b6642028d34abee62 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java @@ -32,6 +32,7 @@ public class PathsTabViewController extends ProjectSettingsTabViewController { File folder = chooser.showDialog(getStage()); if (folder != null) { Path path = folder.toPath(); + mediaPathTextField.setText(path.toString()); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java index 2c86eb3ae252bdddaba728b9d7eb2fb6e32acfb3..b2d5ff3acc5b443952969cda648fdc59df38f73d 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java @@ -1,6 +1,7 @@ package de.tobias.playpad.viewcontroller.pad; import java.io.File; +import java.io.IOException; import java.util.Collection; import java.util.Set; @@ -133,7 +134,7 @@ public class PadDragListener { try { content.handlePath(file.toPath()); - } catch (NoSuchComponentException e) { + } catch (NoSuchComponentException | IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java index 5e8df0ee7a58a6c0beb59751d29896c069b57a64..f0c6f6e74533e0cecab21db1b6a77887f808e4e7 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/conntent/PadContent.java @@ -1,10 +1,14 @@ package de.tobias.playpad.pad.conntent; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import org.dom4j.Element; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.utils.util.ZipFile; @@ -43,15 +47,19 @@ public abstract class PadContent { * @param path * path * @throws NoSuchComponentException - * Wird geworfen, wenn ein Pad eine Componenten nicht laden kann. Beispiel bei Audio das richtige Soundsystem + * Wird geworfen, wenn ein Pad eine Componenten nicht laden kann. Beispiel bei Audio das richtige + * Soundsystem + * @throws IOException + * IO Fehler */ - public abstract void handlePath(Path path) throws NoSuchComponentException; + public abstract void handlePath(Path path) throws NoSuchComponentException, IOException; /** * Lädt die Medien, sodass sie auf abruf verfügbar sind. * * @throws NoSuchComponentException - * Wird geworfen, wenn ein Pad eine Componenten nicht laden kann. Beispiel bei Audio das richtige Soundsystem + * Wird geworfen, wenn ein Pad eine Componenten nicht laden kann. Beispiel bei Audio das richtige + * Soundsystem */ public abstract void loadMedia() throws NoSuchComponentException; @@ -86,4 +94,30 @@ public abstract class PadContent { public abstract void exportMedia(ZipFile zip, Element element); + /** + * Gibt den richtigen Pfad einer Datei zurück, basierend auf den Einstellungen. + * + * @param orrginal + * orginal path + * @return new path + * @throws IOException + * IO Fehler + * @since 5.1.0 + */ + public Path getRealPath(Path orginal) throws IOException { + ProjectSettings settings = getPad().getProject().getSettings(); + if (settings.isUseMediaPath()) { + Path mediaFolder = settings.getMediaPath(); + Path newPath = mediaFolder.resolve(orginal.getFileName()); + + if (Files.notExists(mediaFolder)) { + Files.createDirectories(mediaFolder); + } + + Files.copy(orginal, newPath, StandardCopyOption.REPLACE_EXISTING); + return newPath; + } + return orginal; + } + } \ No newline at end of file diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java index 2aacbe894c4c1683e45cce88f0089b1ba7a26475..9c310081e55225e2ea8fd37d05ddd2526ef9c891 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java @@ -1,6 +1,7 @@ package de.tobias.playpad.mediaplugin.image; import java.io.FileNotFoundException; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -37,14 +38,15 @@ public class ImageContent extends PadContent { } @Override - public void handlePath(Path path) { + public void handlePath(Path path) throws IOException { unloadMedia(); - setPath(path); + setPath(getRealPath(path)); loadMedia(); } @Override - public void setMasterVolume(double masterVolume) {} + public void setMasterVolume(double masterVolume) { + } @Override public String getType() { diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java index 5e5a41d2ebe57715a5140edab8251b7447ee0df7..b4a36a3aac7c1defa53feeed5d9985fc40a6292c 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java @@ -1,5 +1,6 @@ package de.tobias.playpad.mediaplugin.video; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -70,9 +71,9 @@ public class VideoContent extends PadContent implements Pauseable, Durationable } @Override - public void handlePath(Path path) { + public void handlePath(Path path) throws IOException { unloadMedia(); - setPath(path); + setPath(getRealPath(path)); loadMedia(); }