Skip to content
Snippets Groups Projects
Commit 3fd908c5 authored by tobias's avatar tobias
Browse files

Coninue on media folder

parent bc09014c
No related branches found
No related tags found
No related merge requests found
package de.tobias.playpad.viewcontroller.option.project; package de.tobias.playpad.viewcontroller.option.project;
import java.io.File; import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Optional;
import java.util.stream.Stream;
import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadMain;
import de.tobias.playpad.project.Project; import de.tobias.playpad.project.Project;
...@@ -26,6 +29,7 @@ public class PathsTabViewController extends ProjectSettingsTabViewController imp ...@@ -26,6 +29,7 @@ public class PathsTabViewController extends ProjectSettingsTabViewController imp
@FXML private CheckBox useMediaPath; @FXML private CheckBox useMediaPath;
private transient boolean changedMediaPath = false; private transient boolean changedMediaPath = false;
private transient Optional<Path> oldMediaPath = Optional.empty();
public PathsTabViewController() { public PathsTabViewController() {
super("pathTab.fxml", "de/tobias/playpad/assets/view/option/project/", PlayPadMain.getUiResourceBundle()); super("pathTab.fxml", "de/tobias/playpad/assets/view/option/project/", PlayPadMain.getUiResourceBundle());
...@@ -54,6 +58,9 @@ public class PathsTabViewController extends ProjectSettingsTabViewController imp ...@@ -54,6 +58,9 @@ public class PathsTabViewController extends ProjectSettingsTabViewController imp
Path newPath = Paths.get(mediaPathTextField.getText()); Path newPath = Paths.get(mediaPathTextField.getText());
if (!settings.getMediaPath().equals(newPath)) { if (!settings.getMediaPath().equals(newPath)) {
changedMediaPath = true; changedMediaPath = true;
if (settings.getMediaPath() != null && !settings.getMediaPath().toString().isEmpty()) {
oldMediaPath = Optional.of(settings.getMediaPath());
}
} }
if (useMediaPath.isSelected()) { if (useMediaPath.isSelected()) {
...@@ -86,10 +93,26 @@ public class PathsTabViewController extends ProjectSettingsTabViewController imp ...@@ -86,10 +93,26 @@ public class PathsTabViewController extends ProjectSettingsTabViewController imp
@Override @Override
protected Void call() throws Exception { protected Void call() throws Exception {
updateTitle(name()); updateTitle(name());
for (int i = 0; i < 100; i++) { Path newMediaPath = settings.getMediaPath();
Thread.sleep(10);
updateProgress(i, 100); project.closeFile();
int i = 0;
Stream<Path> files = Files.list(oldMediaPath.get());
files.forEach(file ->
{
// BUG Copy not work as expected
try {
Files.copy(file, newMediaPath.resolve(file.getFileName()));
Thread.sleep(500);
} catch (Exception e) {
e.printStackTrace();
} }
updateProgress(i, files.count());
});
files.close();
project.loadPadsContent();
return null; return null;
} }
}; };
......
...@@ -151,7 +151,8 @@ public class Project { ...@@ -151,7 +151,8 @@ public class Project {
if (ref.getProfileReference() != null) { if (ref.getProfileReference() != null) {
Profile.load(ref.getProfileReference()); // Lädt das entsprechende Profile und aktiviert es Profile.load(ref.getProfileReference()); // Lädt das entsprechende Profile und aktiviert es
} else { } else {
Profile profile = profileChooseable.getUnkownProfile(); // Lädt Profile / Erstellt neues und hat es gleich im Speicher Profile profile = profileChooseable.getUnkownProfile(); // Lädt Profile / Erstellt neues und hat es
// gleich im Speicher
ref.setProfileReference(profile.getRef()); ref.setProfileReference(profile.getRef());
} }
...@@ -274,4 +275,12 @@ public class Project { ...@@ -274,4 +275,12 @@ public class Project {
public int getPadCount() { public int getPadCount() {
return pads.size(); return pads.size();
} }
public void closeFile() {
pads.values().forEach(pad ->
{
if (pad.getContent() != null)
pad.getContent().unloadMedia();
});
}
} }
...@@ -91,9 +91,11 @@ public class ProjectSettings { ...@@ -91,9 +91,11 @@ public class ProjectSettings {
settings.setColumns(Integer.valueOf(element.element(COLUMNS_ELEMENT).getStringValue())); settings.setColumns(Integer.valueOf(element.element(COLUMNS_ELEMENT).getStringValue()));
if (element.element(ROWS_ELEMENT) != null) if (element.element(ROWS_ELEMENT) != null)
settings.setRows(Integer.valueOf(element.element(ROWS_ELEMENT).getStringValue())); settings.setRows(Integer.valueOf(element.element(ROWS_ELEMENT).getStringValue()));
if (element.element(MEDIA_PATH_ELEMENT) != null) {
settings.setMediaPath(Paths.get(element.element(MEDIA_PATH_ELEMENT).getStringValue())); Element mediaElement = element.element(MEDIA_PATH_ELEMENT);
settings.setUseMediaPath(Boolean.valueOf(element.attributeValue(MEDIA_PATH_ACTIVE_ATTR))); if (mediaElement != null) {
settings.setMediaPath(Paths.get(mediaElement.getStringValue()));
settings.setUseMediaPath(Boolean.valueOf(mediaElement.attributeValue(MEDIA_PATH_ACTIVE_ATTR)));
} }
return settings; return settings;
......
...@@ -7,8 +7,11 @@ import java.util.ResourceBundle; ...@@ -7,8 +7,11 @@ import java.util.ResourceBundle;
import de.tobias.playpad.mediaplugin.main.VideoSettings; import de.tobias.playpad.mediaplugin.main.VideoSettings;
import de.tobias.playpad.project.Project; import de.tobias.playpad.project.Project;
import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.Profile;
import de.tobias.playpad.settings.ProfileSettings;
import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController;
import de.tobias.playpad.viewcontroller.option.IProfileReloadTask;
import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController;
import javafx.concurrent.Task;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.CheckBox; import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox; import javafx.scene.control.ComboBox;
...@@ -19,7 +22,7 @@ import javafx.scene.paint.Color; ...@@ -19,7 +22,7 @@ import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import javafx.stage.Screen; import javafx.stage.Screen;
public class MediaSettingsTabViewController extends ProfileSettingsTabViewController { public class MediaSettingsTabViewController extends ProfileSettingsTabViewController implements IProfileReloadTask {
@FXML private Pane screenViewPane; @FXML private Pane screenViewPane;
@FXML private ComboBox<Integer> screenComboBox; @FXML private ComboBox<Integer> screenComboBox;
...@@ -118,13 +121,22 @@ public class MediaSettingsTabViewController extends ProfileSettingsTabViewContro ...@@ -118,13 +121,22 @@ public class MediaSettingsTabViewController extends ProfileSettingsTabViewContro
} }
@Override @Override
public void reload(Profile profile, Project project, IMainViewController controller) { public boolean validSettings() {
MediaPluginImpl.getInstance().getVideoViewController().reloadSettings(); return true;
} }
@Override @Override
public boolean validSettings() { public Task<Void> getTask(ProfileSettings settings, Project project, IMainViewController controller) {
return true; return new Task<Void>() {
@Override
protected Void call() throws Exception {
updateProgress(-1, -1);
updateTitle(name());
MediaPluginImpl.getInstance().getVideoViewController().reloadSettings();
return null;
}
};
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment