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

Add media path option in NewProjectView

parent 8f1b88fc
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,24 @@
<TextField fx:id="nameTextField" prefWidth="200.0" HBox.hgrow="ALWAYS" />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="14.0">
<children>
<Label alignment="CENTER_RIGHT" minWidth="100.0" prefWidth="100.0" text="%newProject.label.media" />
<VBox spacing="14.0">
<children>
<CheckBox fx:id="mediaPathCheckbox" mnemonicParsing="false" text="%newProject.checkbox.mediafolder" />
<HBox alignment="CENTER_LEFT" spacing="14.0">
<children>
<Button fx:id="mediaButtonChoose" minWidth="-Infinity" mnemonicParsing="false" onAction="#mediaButtonHandler" text="%newProject.button.media" />
<Label fx:id="mediaPathLabel" textOverrun="CENTER_ELLIPSIS" HBox.hgrow="ALWAYS" />
</children>
</HBox>
</children>
</VBox>
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="14.0">
<children>
<Label alignment="CENTER_RIGHT" minWidth="100.0" prefWidth="100.0" text="%newProject.label.profile" HBox.hgrow="NEVER" />
......
......@@ -74,7 +74,8 @@ UI.Dialog.DragAndDrop.Button=OK
UI.Dialog.NewProfile.Content=Geben Sie einen Namen für das neue Profil ein:
# UI - Dialog - NewProject
UI.Dialog.NewProject.Content=Geben Sie einen Namen für das neue Projekt ein.
UI.Dialog.NewProject.Content=Geben Sie einen Namen für das neue Projekt ein:
UI.Dialog.NewProject.MediaPath=Sie müssen erst einen Ordner für die Mediendateien festlegen, bevor das Projekt erstellt werden kann.
# UI - Dialog - Import
UI.Dialog.Import.ReplaceProfile.Content=Es gibt bereits eine Profil mit dem Namen {}. Bitte geben Sie einen anderen Namen ein.
......
......@@ -178,6 +178,10 @@ plugin.button.finish=Fertig
settings.audio.type=Ausgabe Type whlen:
newProject.label.name=Name:
newProject.label.media=Media Ordner:
newProject.checkbox.mediafolder=Media Ordner nutzen (Benutze Dateien werden dort hin kopiert)
newProject.button.media=Media Ordner whlen
newProject.label.profile=Profil:
newProject.button.newProfile=Neues Profil...
newProject.button.finish=Projekt erstellen
......
......@@ -71,7 +71,8 @@ public class Strings {
public static final String UI_Dialog_NewProfile_Content = "UI.Dialog.NewProfile.Content";
// UI - Dialog - NewProject
public static final String UI_Dialog_NewProject_Content = "UI.Dialog.NewProject.Content";
public static final String UI_Dialog_NewProject_Content = "UI.Dialog.NewProject.Content"; // Duplicate Project
public static final String UI_Dialog_NewProject_Media = "UI.Dialog.NewProject.MediaPath"; // Create Project
// UI - Dialog - Import
public static final String UI_Dialog_Import_ReplaceProfile_Content = "UI.Dialog.Import.ReplaceProfile.Content";
......
package de.tobias.playpad.viewcontroller.dialog;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.UUID;
import org.dom4j.DocumentException;
......@@ -17,8 +19,11 @@ import de.tobias.utils.util.Localization;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.DirectoryChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
......@@ -35,10 +40,16 @@ public class NewProjectDialog extends ViewController {
@FXML private ComboBox<ProfileReference> profileComboBox;
@FXML private Button newProfileButton;
// Media Path
@FXML private CheckBox mediaPathCheckbox;
@FXML private Button mediaButtonChoose;
@FXML private Label mediaPathLabel;
@FXML private Button finishButton;
@FXML private Button cancelButton;
private Project project;
private Path newMediaPath; // Ausgewählter Ordner (temp)
public NewProjectDialog(Window owner) {
super("newProjectDialog", "de/tobias/playpad/assets/dialog/", null, PlayPadMain.getUiResourceBundle());
......@@ -66,6 +77,15 @@ public class NewProjectDialog extends ViewController {
});
finishButton.setDisable(true);
mediaPathCheckbox.selectedProperty().addListener((a, b, c) ->
{
mediaButtonChoose.setDisable(!c);
if (!c) {
mediaPathLabel.setText("");
newMediaPath = null;
}
});
addCloseKeyShortcut(() -> getStage().close());
}
......@@ -75,10 +95,10 @@ public class NewProjectDialog extends ViewController {
stage.setTitle(Localization.getString(Strings.UI_Dialog_NewProject_Title));
stage.setWidth(560);
stage.setHeight(250);
stage.setHeight(380);
stage.setMinWidth(560);
stage.setMinHeight(250);
stage.setMinHeight(380);
stage.setMaxWidth(560);
......@@ -87,17 +107,34 @@ public class NewProjectDialog extends ViewController {
}
}
@FXML
private void mediaButtonHandler(ActionEvent event) {
if (mediaPathCheckbox.isSelected()) {
DirectoryChooser chooser = new DirectoryChooser();
File file = chooser.showDialog(getStage());
if (file != null) {
newMediaPath = file.toPath();
mediaPathLabel.setText(newMediaPath.toString());
}
}
}
@FXML
private void finishButtonHandler(ActionEvent evenet) {
if (mediaPathCheckbox.isSelected() && newMediaPath == null) {
showInfoMessage(Localization.getString(Strings.UI_Dialog_NewProject_Content));
return;
}
try {
Profile profile = Profile.load(profileComboBox.getSelectionModel().getSelectedItem());
String name = nameTextField.getText();
UUID uuid = UUID.randomUUID();
ProjectReference projectReference = new ProjectReference(uuid, name, profile.getRef());
project = new Project(projectReference);
project.getSettings().setUseMediaPath(mediaPathCheckbox.isSelected());
project.getSettings().setMediaPath(newMediaPath);
project.save();
ProjectReference.addProject(projectReference);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment