diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties index cae2209260275be3c7b92c311c6080f0156b0ed4..2d94039b6ff8ca449636c55d893d31ab0eff5839 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties @@ -50,7 +50,7 @@ UI.Layout.Classic.Theme.LIGHT=Hell # UI - Window - Main UI.Window.Main.CloseRequest=Es wird gerade noch Musik abgespielt. M�chten Sie PlayWall trotzdem beenden? UI.Window.Main.SaveRequest=M�chten Sie die �nderungen speichern? -UI.Window.Main.PageButton = Seite {} +UI.Window.Main.PageButton=Seite {} # UI - Dialog - Launch UI.Dialog.Launch.Info={} - {} diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties index 9438e06b62639682604ff2e1351a3afefbc41a97..cdc05e376046c786b0040e53573933f7eef7f0a6 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties @@ -231,6 +231,8 @@ triggertime.label.time=Zeit vom Trigger: (Sek) carttrigger.label.action=Aktion f�r Kacheln: carttrigger.label.carts=Kacheln: carttrigger.checkbox.all=Alle anderen Kacheln +carttrigger.label.add.placeholder=Hinzuf�gen (Name der Kachel) +carttrigger.button.add=Hinzuf�gen volumetrigger.label.volume=Lautst�rke: volumetrigger.label.duration=�berblenddauer: \ No newline at end of file diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/pad/trigger/cartTrigger.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/pad/trigger/cartTrigger.fxml index 3aee2f7dda47d7fcd51ad973ddb0a0a4a4ea055b..2043f7d953b159897da9d9bb6f0fa0780c79504a 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/pad/trigger/cartTrigger.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/pad/trigger/cartTrigger.fxml @@ -18,7 +18,13 @@ <VBox spacing="14.0"> <children> <CheckBox fx:id="allCartsCheckbox" mnemonicParsing="false" text="%carttrigger.checkbox.all" /> - <TextField fx:id="cartTextField" prefWidth="150.0" promptText="1, 3-5" /> + <HBox spacing="14.0"> + <children> + <TextField fx:id="cartTextField" prefWidth="150.0" promptText="%carttrigger.label.add.placeholder" /> + <Button fx:id="addButton" mnemonicParsing="false" onAction="#addHandler" text="%carttrigger.button.add" /> + </children> + </HBox> + <ListView fx:id="addedCarts" prefHeight="200.0" prefWidth="200.0" /> </children> </VBox> </children> diff --git a/PlayWall/src/application.yml b/PlayWall/src/application.yml index 4ed0bd37d618f8b78403b3a82be171e26e437731..357a198151a7d253a312fb76ef1b898f692e5f6e 100644 --- a/PlayWall/src/application.yml +++ b/PlayWall/src/application.yml @@ -1,7 +1,7 @@ name: PlayWall -version: 5.1.0 -build: 35 -identifier: de.tobias.playpad +version: 6.0.0 +build: 36 +identifier: de.tobias.playpad.v6 main: de.tobias.playpad.PlayPadMain author: Tobias Ullerich backup: false diff --git a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java index 83b0ae9f158a67dd7b75e20541b165c2d9be331b..742a63bb0f84e2200bdc3ac579396988abd9b61a 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java @@ -57,6 +57,7 @@ public class PlayPadImpl implements PlayPad { private MainViewController mainViewController; private Project currentProject; + protected GlobalSettings globalSettings; public PlayPadImpl(GlobalSettings globalSettings) { diff --git a/PlayWall/src/de/tobias/playpad/PlayPadMain.java b/PlayWall/src/de/tobias/playpad/PlayPadMain.java index 517b73e187e6c59f30fd999ffb05aba942ee1695..6f49ecf00296ce1ea52dccf732e03f08b46c91de 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadMain.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadMain.java @@ -10,7 +10,7 @@ import java.util.ResourceBundle; import java.util.UUID; import de.tobias.playpad.project.Project; -import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.ProfileReference; import de.tobias.playpad.update.PlayPadUpdater; diff --git a/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java b/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java index b6cc56cdb510a9ee0cca3e9a6798661221e92150..15796b6fc3052711b3690481fb6c1f4b6cb1d666 100644 --- a/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java +++ b/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java @@ -22,9 +22,7 @@ import javafx.beans.property.StringProperty; public class CartAction extends Action implements ColorAdjustable { public enum ControlMode { - PLAY_PAUSE, - PLAY_STOP, - PLAY_HOLD; + PLAY_PAUSE, PLAY_STOP, PLAY_HOLD; } private int x; diff --git a/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java b/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java index f9c5a4651d921efb605128d8810b0c5558da32e6..a51a95c82104478992328406eab1cf45395c4b0f 100644 --- a/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java +++ b/PlayWall/src/de/tobias/playpad/audio/JavaFXAudioHandler.java @@ -126,7 +126,7 @@ public class JavaFXAudioHandler extends AudioHandler implements Equalizable { } }); loadedProperty.set(false); - getContent().getPad().throwException(path, player.getError()); +// getContent().getPad().throwException(path, player.getError()); TODO Error Handling User }); player.setOnEndOfMedia(() -> { if (!getContent().getPad().getPadSettings().isLoop()) { diff --git a/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandler.java b/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandler.java index c25c2f83d9a86a357330e34afb167610f5a0e733..26c418195d351bd343a6f828b859c13be3fc1602 100644 --- a/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandler.java +++ b/PlayWall/src/de/tobias/playpad/audio/TinyAudioHandler.java @@ -248,7 +248,7 @@ public class TinyAudioHandler extends AudioHandler { }); } catch (Exception e) { loadedProperty.set(false); - getContent().getPad().throwException(path, e); +// getContent().getPad().throwException(path, e); TODO Error Handling User e.printStackTrace(); } finally { Platform.runLater(() -> diff --git a/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java index e317fc50cd6c4398292a962305ef26245ed71344..76d1ecb40bad3460d5c297150fec084d65b621b3 100644 --- a/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java @@ -324,7 +324,7 @@ public class ClassicGlobalDesign extends Design implements GlobalDesign { String css = convertToCSS("", isCustomLayout()); // Pad Spezelles Layout immer - for (Pad pad : project.getPads().values()) { + for (Pad pad : project.getPads()) { PadSettings padSettings = pad.getPadSettings(); if (padSettings.isCustomLayout()) { diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java index 8a1903ab15afc82900c77eb0bca03a8d6c57f9b3..08f9fa176eb0c24f1a3e860ef30e69dba2746491 100644 --- a/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java @@ -195,7 +195,7 @@ public class ModernGlobalDesign extends Design implements GlobalDesign, DesignCo String css = convertToCSS(); // Pad Spezelles Layout immer - for (Pad pad : project.getPads().values()) { + for (Pad pad : project.getPads()) { PadSettings padSettings = pad.getPadSettings(); if (padSettings.isCustomLayout()) { diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopButtonEditView.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopButtonEditView.java new file mode 100644 index 0000000000000000000000000000000000000000..a4a3f4daf4a9a630940baecf9eb99c2e3bb950ee --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopButtonEditView.java @@ -0,0 +1,103 @@ +package de.tobias.playpad.layout.desktop; + +import java.util.Optional; + +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.Strings; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.page.Page; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.utils.ui.icon.FontAwesomeType; +import de.tobias.utils.ui.icon.FontIcon; +import de.tobias.utils.util.Localization; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.control.Button; +import javafx.scene.control.TextInputDialog; +import javafx.scene.layout.HBox; + +public class DesktopButtonEditView extends HBox implements EventHandler<ActionEvent> { + + private Page page; + private Button leftMoveButton; + private Button rightMoveButton; + private Button editTextButton; + + private transient Button pageButton; + + public DesktopButtonEditView(Page page, Button pageButton) { + this.page = page; + this.pageButton = pageButton; + + leftMoveButton = new Button("", new FontIcon(FontAwesomeType.ARROW_LEFT)); + leftMoveButton.setOnAction(this); + leftMoveButton.setFocusTraversable(false); + + rightMoveButton = new Button("", new FontIcon(FontAwesomeType.ARROW_RIGHT)); + rightMoveButton.setOnAction(this); + rightMoveButton.setFocusTraversable(false); + + editTextButton = new Button("", new FontIcon(FontAwesomeType.EDIT)); + editTextButton.setOnAction(this); + editTextButton.setFocusTraversable(false); + + getChildren().addAll(leftMoveButton, rightMoveButton, editTextButton); + setSpacing(7); + } + + @Override + public void handle(ActionEvent event) { + if (event.getSource() == leftMoveButton) { + Project project = page.getProjectReference(); + if (page.getId() > 0) { + Page leftPage = project.getPage(page.getId() - 1); + + int leftIndex = leftPage.getId(); + int rightIndex = page.getId(); + + project.setPage(rightIndex, leftPage); + project.setPage(leftIndex, page); + + IMainViewController controller = PlayPadPlugin.getImplementation().getMainViewController(); + if (controller.getMenuToolbarController() != null) + controller.getMenuToolbarController().initPageButtons(); + controller.showPage(leftIndex); + } + event.consume(); + } else if (event.getSource() == rightMoveButton) { + Project project = page.getProjectReference(); + if (page.getId() < project.getSettings().getPageCount()) { + Page rightPage = project.getPage(page.getId() + 1); + + int rightIndex = rightPage.getId(); + int leftIndex = page.getId(); + + project.setPage(leftIndex, rightPage); + project.setPage(rightIndex, page); + + IMainViewController controller = PlayPadPlugin.getImplementation().getMainViewController(); + if (controller.getMenuToolbarController() != null) + controller.getMenuToolbarController().initPageButtons(); + controller.showPage(rightIndex); + } + event.consume(); + } else if (event.getSource() == editTextButton) { + TextInputDialog dialog = new TextInputDialog(); + Optional<String> result = dialog.showAndWait(); + // TODO Owner, Modal, Icon, Text + result.ifPresent(name -> + { + page.setName(name); + }); + + String name = page.getName(); + if (name.isEmpty()) { + name = Localization.getString(Strings.UI_Window_Main_PageButton, (page.getId() + 1)); + } + pageButton.setText(name); + + event.consume(); + } + } + +} diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index 6fe5003cf5241fdb29778da90997145b657d2ab7..d130626ee700e48dae98cd463ce9d097000b2567 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -20,7 +20,8 @@ import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectNotFoundException; -import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.project.page.Page; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.registry.Registry; import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; @@ -171,6 +172,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @Override public void initPageButtons() { + currentPage = -1; pageHBox.getChildren().clear(); if (openProject == null) { @@ -178,7 +180,14 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro } for (int i = 0; i < openProject.getSettings().getPageCount(); i++) { - Button button = new Button(Localization.getString(Strings.UI_Window_Main_PageButton, (i + 1))); + Page page = openProject.getPage(i); + + String name = page.getName(); + if (name.isEmpty()) { + name = Localization.getString(Strings.UI_Window_Main_PageButton, (i + 1)); + } + + Button button = new Button(name); button.setUserData(i); button.setOnDragOver(new PageButtonDragHandler(mainViewController, i)); button.setFocusTraversable(false); @@ -297,15 +306,25 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @Override public void highlightPageButton(int index) { if (index >= 0) { - if (pageHBox.getChildren().size() > currentPage) { + if (pageHBox.getChildren().size() > currentPage && currentPage >= 0) { Node removeNode = pageHBox.getChildren().get(currentPage); removeNode.getStyleClass().remove(CURRENT_PAGE_BUTTON); + + if (removeNode instanceof Button) { + ((Button) removeNode).setGraphic(null); + } } if (pageHBox.getChildren().size() > index) { Node newNode = pageHBox.getChildren().get(index); newNode.getStyleClass().add(CURRENT_PAGE_BUTTON); currentPage = index; + + if (newNode instanceof Button && dndModeMenuItem.isSelected()) { // Nur bei Drag And Drop mode + Button button = (Button) newNode; + DesktopButtonEditView editBox = new DesktopButtonEditView(openProject.getPage(index), button); + button.setGraphic(editBox); + } } } } @@ -330,9 +349,8 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro doAction(() -> { Stage stage = mainViewController.getStage(); - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - ProjectManagerDialog view = new ProjectManagerDialog(stage, currentProject); + ProjectManagerDialog view = new ProjectManagerDialog(stage, openProject); Optional<ProjectReference> result = view.showAndWait(); if (result.isPresent()) { @@ -367,10 +385,8 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void saveMenuHandler(ActionEvent event) { - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - try { - currentProject.save(); + openProject.save(); mainViewController.notify(Localization.getString(Strings.Standard_File_Save), PlayPadMain.displayTimeMillis); } catch (IOException e) { mainViewController.showError(Localization.getString(Strings.Error_Project_Save)); @@ -382,9 +398,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro void profileMenuHandler(ActionEvent event) { doAction(() -> { - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - - ProfileViewController controller = new ProfileViewController(mainViewController.getStage(), currentProject); + ProfileViewController controller = new ProfileViewController(mainViewController.getStage(), openProject); controller.getStage().showAndWait(); mainViewController.updateWindowTitle(); }); @@ -392,8 +406,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void printMenuHandler(ActionEvent event) { - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - PrintDialog dialog = new PrintDialog(currentProject, mainViewController.getStage()); + PrintDialog dialog = new PrintDialog(openProject, mainViewController.getStage()); dialog.getStage().show(); } @@ -416,6 +429,8 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro } } + // Damit werden Page Buttons editierbar (die 3 Button vom DesktopButtonEditView) + highlightPageButton(currentPage); } @FXML @@ -434,19 +449,15 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void projectSettingsHandler(ActionEvent event) { - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - if (projectSettingsViewController == null) { Stage mainStage = mainViewController.getStage(); Runnable onFinish = () -> { projectSettingsViewController = null; - mainStage.toFront(); }; - projectSettingsViewController = new ProjectSettingsViewController(mainViewController.getScreen(), mainStage, currentProject, - onFinish); + projectSettingsViewController = new ProjectSettingsViewController(mainViewController.getScreen(), mainStage, openProject, onFinish); projectSettingsViewController.getStage().show(); } else if (projectSettingsViewController.getStage().isShowing()) { @@ -458,9 +469,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro void profileSettingsHandler(ActionEvent event) { Midi midi = Midi.getInstance(); Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); - if (settings.isLiveMode() && settings.isLiveModeSettings() && currentProject.getActivePlayers() > 0) { return; } @@ -476,7 +485,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro mainStage.toFront(); }; - profileSettingsViewController = new ProfileSettingsViewController(midi, mainViewController.getScreen(), mainStage, currentProject, + profileSettingsViewController = new ProfileSettingsViewController(midi, mainViewController.getScreen(), mainStage, openProject, onFinish); profileSettingsViewController.getStage().show(); @@ -531,8 +540,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro pane.show("", box); // Auto Complete - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - Set<String> names = currentProject.getPads().values().stream().filter(p -> p.getStatus() != PadStatus.EMPTY).map(Pad::getName) + Set<String> names = openProject.getPads().stream().filter(p -> p.getStatus() != PadStatus.EMPTY).map(Pad::getName) .collect(Collectors.toSet()); TextFields.bindAutoCompletion(field, names); } @@ -585,7 +593,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro public void createRecentDocumentMenuItems() { recentOpenMenu.getItems().clear(); - String project = openProject.getRef().getName(); + String project = openProject.getProjectReference().getName(); ProjectReference.getProjectsSorted().stream().filter(item -> !item.getName().equals(project)).limit(LAST_DOCUMENT_LIMIT).forEach(item -> { diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java index ddeb4138d48ceeb95bdbc745018e02049f0884c5..df1a4f755e5b2ac012e813bb722a9a2f2c658793 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java @@ -1,13 +1,6 @@ package de.tobias.playpad.layout.desktop; -import de.tobias.playpad.PlayPadMain; -import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.Strings; -import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.project.Project; import de.tobias.utils.ui.Alertable; -import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.control.TextField; @@ -26,28 +19,28 @@ public class DesktopSearchController implements EventHandler<ActionEvent> { @Override public void handle(ActionEvent event) { - if (textField.getText().isEmpty()) { - return; - } - - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - main: for (int i = currentIndex; i < currentProject.getPadCount(); i++) { - Pad pad = currentProject.getPad(i); - if (pad.getStatus() != PadStatus.EMPTY) { - if (pad.getName().startsWith(textField.getText())) { - while (pad.getController() == null) { - if (!PlayPadPlugin.getImplementation().getMainViewController() - .showPage(PlayPadPlugin.getImplementation().getMainViewController().getPage() + 1)) { - break main; - } - } - pad.getController().getView().highlightView(3); - currentIndex = i + 1; - return; - } - } - } - alertable.showInfoMessage(Localization.getString(Strings.Search_Alert_NoMatches), PlayPadMain.stageIcon.orElse(null)); - currentIndex = 0; +// if (textField.getText().isEmpty()) { +// return; +// } +// +// Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); +// main: for (int i = currentIndex; i < currentProject.getPadCount(); i++) { +// Pad pad = currentProject.getPad(i); +// if (pad.getStatus() != PadStatus.EMPTY) { +// if (pad.getName().startsWith(textField.getText())) { +// while (pad.getController() == null) { +// if (!PlayPadPlugin.getImplementation().getMainViewController() +// .showPage(PlayPadPlugin.getImplementation().getMainViewController().getPage() + 1)) { +// break main; +// } +// } +// pad.getController().getView().highlightView(3); +// currentIndex = i + 1; +// return; +// } +// } +// } +// alertable.showInfoMessage(Localization.getString(Strings.Search_Alert_NoMatches), PlayPadMain.stageIcon.orElse(null)); +// currentIndex = 0; } } diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java index 8d68d5e6a08f27cc473292cf326b645f3d36c1ef..4e23c6ac8ed28a00b7a12187e0f3fc459274e525 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java @@ -1,6 +1,5 @@ package de.tobias.playpad.layout.touch; -import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.PseudoClasses; import de.tobias.playpad.pad.Pad; diff --git a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java index 2d9b220013ad986e4502722119ec04c91fe980fb..5740b39ae23884ca466fd2397357450873361f15 100644 --- a/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java +++ b/PlayWall/src/de/tobias/playpad/pad/content/AudioContent.java @@ -1,6 +1,5 @@ package de.tobias.playpad.pad.content; -import java.io.FileNotFoundException; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -232,7 +231,7 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, getPad().getPadSettings().volumeProperty().addListener(volumeListener); getPad().customVolumeProperty().addListener(customVolumeListener); } else { - getPad().throwException(path, new FileNotFoundException()); + // getPad().throwException(path, new FileNotFoundException()); TODO Error Handling User } } diff --git a/PlayWall/src/de/tobias/playpad/pad/drag/MoveDragMode.java b/PlayWall/src/de/tobias/playpad/pad/drag/MoveDragMode.java index 16a3526c19e4f374654150a47327d6f7be972f9b..d79ce380063088d23253c72974dc2e1d4b449b5e 100644 --- a/PlayWall/src/de/tobias/playpad/pad/drag/MoveDragMode.java +++ b/PlayWall/src/de/tobias/playpad/pad/drag/MoveDragMode.java @@ -3,6 +3,7 @@ package de.tobias.playpad.pad.drag; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.page.PadIndex; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.util.Localization; @@ -40,7 +41,7 @@ public class MoveDragMode extends PadDragMode { } @Override - public void handle(int oldIndex, int newIndex, Project project) { + public void handle(PadIndex oldIndex, PadIndex newIndex, Project project) { Pad oldPad = project.getPad(oldIndex); Pad newPad = project.getPad(newIndex); diff --git a/PlayWall/src/de/tobias/playpad/pad/drag/ReplaceDragMode.java b/PlayWall/src/de/tobias/playpad/pad/drag/ReplaceDragMode.java index 0e48d10e02295c9bc053efd83d7ec5bf19383967..107bcf13e74a3101ff8efee3dc05417a4c7d6541 100644 --- a/PlayWall/src/de/tobias/playpad/pad/drag/ReplaceDragMode.java +++ b/PlayWall/src/de/tobias/playpad/pad/drag/ReplaceDragMode.java @@ -3,6 +3,7 @@ package de.tobias.playpad.pad.drag; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.page.PadIndex; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.util.Localization; @@ -40,11 +41,11 @@ public class ReplaceDragMode extends PadDragMode { } @Override - public void handle(int oldPad, int newPad, Project project) { + public void handle(PadIndex oldPad, PadIndex newPad, Project project) { Pad srcPad = project.getPad(oldPad); project.setPad(newPad, srcPad); - project.setPad(oldPad, new Pad(project, oldPad)); + project.setPad(oldPad, new Pad(project, oldPad)); // Leeres Pad an den Index } } diff --git a/PlayWall/src/de/tobias/playpad/trigger/CartTriggerItem.java b/PlayWall/src/de/tobias/playpad/trigger/CartTriggerItem.java index b7e056734a4a0985f231369a7ec3e77018f886b4..631f2e8f1aa5a5921c09ad4d646dd84460cc13d4 100644 --- a/PlayWall/src/de/tobias/playpad/trigger/CartTriggerItem.java +++ b/PlayWall/src/de/tobias/playpad/trigger/CartTriggerItem.java @@ -2,6 +2,7 @@ package de.tobias.playpad.trigger; import java.util.ArrayList; import java.util.List; +import java.util.UUID; import org.dom4j.Element; @@ -14,19 +15,19 @@ import de.tobias.playpad.viewcontroller.main.IMainViewController; public class CartTriggerItem extends TriggerItem { - private List<Integer> carts; + private List<UUID> uuids; private boolean allCarts; private PadStatus newStatus; // Only Play, Pause, Stop public CartTriggerItem() { newStatus = PadStatus.PLAY; allCarts = false; - carts = new ArrayList<Integer>() { + uuids = new ArrayList<UUID>() { private static final long serialVersionUID = 1L; @Override - public boolean add(Integer e) { + public boolean add(UUID e) { if (!contains(e)) return super.add(e); else @@ -35,8 +36,8 @@ public class CartTriggerItem extends TriggerItem { }; } - public List<Integer> getCarts() { - return carts; + public List<UUID> getCarts() { + return uuids; } public boolean isAllCarts() { @@ -62,16 +63,22 @@ public class CartTriggerItem extends TriggerItem { } @Override - public void performAction(Pad pad, Project project, IMainViewController controller, Profile profile) { + public void performAction(Pad source, Project project, IMainViewController controller, Profile profile) { if (allCarts) { - for (Pad cart : project.getPads().values()) { - if (cart.getIndex() != pad.getIndex()) + for (Pad cart : project.getPads()) { + if (cart.getUuid().equals(source.getUuid())) cart.setStatus(newStatus); } } else { - for (int cart : carts) { - if (cart != pad.getIndex()) - project.getPad(cart).setStatus(newStatus); + System.out.println(uuids); + // TODO Cart Trigger mit Pages und Index --> PadIndex + for (UUID uuid : uuids) { + if (!uuid.equals(source.getUuid())) { + Pad pad = project.getPad(uuid); + System.out.println(pad); + if (pad != null) + pad.setStatus(newStatus); + } } } } @@ -92,7 +99,7 @@ public class CartTriggerItem extends TriggerItem { for (Object cartObj : element.elements(CART_ELEMENT)) { if (cartObj instanceof Element) { Element cartElement = (Element) cartObj; - carts.add(Integer.valueOf(cartElement.getStringValue())); + uuids.add(UUID.fromString(cartElement.getStringValue())); } } } @@ -104,64 +111,9 @@ public class CartTriggerItem extends TriggerItem { element.addAttribute(STATUS_ATTR, newStatus.name()); element.addAttribute(ALLCARTS_ATTR, String.valueOf(allCarts)); - for (int cart : carts) { + for (UUID cart : uuids) { Element cartElement = element.addElement(CART_ELEMENT); cartElement.addText(String.valueOf(cart)); } } - - public void setCartsString(String string) { - if (string != null) { - carts.clear(); - string = string.replace(" ", ""); - for (String part : string.split(",")) { - if (part.contains("-")) { - if (part.split("-").length == 2) { - int start = Integer.valueOf(part.split("-")[0]); - int end = Integer.valueOf(part.split("-")[1]); - - for (int i = start; i <= end; i++) { - carts.add(i - 1); - } - } - } else { - int cart = Integer.valueOf(part); - carts.add(cart - 1); - } - } - carts.sort(Integer::compareTo); - } - } - - public String getCartsString() { - String string = ""; - int startValue = -1; - - for (int i = 0; i < carts.size(); i++) { - if (i + 1 < carts.size()) { - if (carts.get(i) + 1 == carts.get(i + 1)) { - if (startValue == -1) { - startValue = carts.get(i); - } - } else { - if (startValue != -1) - string += (startValue + 1) + "-" + (carts.get(i) + 1) + ","; - else - string += (carts.get(i) + 1) + ","; - startValue = -1; - - } - } else { - if (startValue == -1) { - string += (carts.get(i) + 1) + ","; - } else { - string += (startValue + 1) + "-" + (carts.get(i) + 1) + ","; - } - } - } - if (string.isEmpty()) { - return null; - } - return string.substring(0, string.length() - 1); - } } diff --git a/PlayWall/src/de/tobias/playpad/trigger/VolumeTriggerItem.java b/PlayWall/src/de/tobias/playpad/trigger/VolumeTriggerItem.java index c9a6ce6b351d09cb7ddc1160ecf40b8d3350768d..208dc5a8d982b769d7a0d05a4e5d8de8ddf805a9 100644 --- a/PlayWall/src/de/tobias/playpad/trigger/VolumeTriggerItem.java +++ b/PlayWall/src/de/tobias/playpad/trigger/VolumeTriggerItem.java @@ -54,7 +54,7 @@ public class VolumeTriggerItem extends TriggerItem { @Override protected void interpolate(double frac) { - for (Pad p : project.getPads().values()) { + for (Pad p : project.getPads()) { if (p.getIndex() != pad.getIndex()) { if (p.getCustomVolume() > volume) { p.setCustomVolume(currentValue - frac * (currentValue - volume)); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java index d659f482f881527f96cb000d17c10405ec4c776d..7c60c0c172218034755d41d1b90b75164cd9c5fe 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java @@ -11,10 +11,10 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.project.ProfileChooseable; -import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectImporter; import de.tobias.playpad.project.ProjectNotFoundException; -import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileNotFoundException; import de.tobias.playpad.viewcontroller.cell.ProjectCell; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java index 6326b9c7015b56a4e6510a47bde8cd42676311bd..ee150b2c7b9b73157548f784dd6e612f74af29d9 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java @@ -8,8 +8,8 @@ import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.action.Mapping; import de.tobias.playpad.action.cartaction.CartAction; import de.tobias.playpad.action.connect.CartActionConnect; -import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.project.Project; import de.tobias.playpad.viewcontroller.IMappingTabViewController; import de.tobias.utils.ui.ContentViewController; import javafx.fxml.FXML; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java index 650064aac576b12399d42c650a4b3309f3de78ae..7100364822a123445647c6b63f5efe6d9dbf340f 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/ProjectCell.java @@ -4,7 +4,7 @@ import java.nio.file.Files; import java.nio.file.Path; import de.tobias.playpad.Displayable; -import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.ProfileReference; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/FixCell.java b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/FixCell.java index 2e6e65f3117abbed7dff065272484dd5180b5fba..f183023a8b30443342387262f075fc8a552c50b1 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/FixCell.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/cell/errordialog/FixCell.java @@ -52,7 +52,7 @@ public class FixCell extends TableCell<PadException, PadException> { deleteButton.setOnAction(a -> { deleteExButton.getHandler().handle(item.getPad(), stage); - item.getPad().getProject().removeException(item); + // item.getPad().getProject().removeException(item);TODO Error Handling User }); vbox.getChildren().add(deleteButton); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java index 180f5230e0b9fde768b3a71c8e065bf3a65d3b50..b31808a79568be8d99f6214cff746a0799f45ff1 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java @@ -5,7 +5,7 @@ import java.util.Optional; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.project.Project; -import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.ProfileReference; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ErrorSummaryDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ErrorSummaryDialog.java index 7e83853ccb61db8e51b022cdde2bb5b7347b557e..5a5b64dfd8e618c6444058c6697477f8bf72991d 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ErrorSummaryDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ErrorSummaryDialog.java @@ -72,7 +72,8 @@ public class ErrorSummaryDialog extends ViewController { string = Localization.getString(Strings.Error_Pad_BaseName + padException.getType().name(), padException.getPad().getIndexReadable()); else - string = Localization.getString(Strings.Error_Pad_BaseName + padException.getType().name(), padException.getPath().toString()); + string = Localization.getString(Strings.Error_Pad_BaseName + padException.getType().name(), + padException.getPath().toString()); } catch (Exception e) { e.printStackTrace(); } @@ -94,7 +95,7 @@ public class ErrorSummaryDialog extends ViewController { } public void setProject(Project project) { - errorTable.setItems(project.getExceptions()); + // errorTable.setItems(project.getExceptions()); TODO Error Handling User errorTable.getItems().addListener(new ListChangeListener<PadException>() { @Override diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java index 47352aa2fb1383ef5cc6ab84be004c91033714d5..58d17b37c38775d5aa2a998ffee99501b209a1d5 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java @@ -10,7 +10,7 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.project.Project; -import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileNotFoundException; import de.tobias.playpad.settings.ProfileReference; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java index 71d6ca6354fbd3c34fddb557ed30c3f5d97e9f77..8c895f0c67858fe7ce2520f83c19da7c27ea96fb 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java @@ -11,8 +11,9 @@ import com.hp.gagawa.java.elements.Tr; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.page.PadIndex; import de.tobias.playpad.settings.Profile; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.ui.ViewController; @@ -83,7 +84,7 @@ public class PrintDialog extends ViewController { H1 header = new H1(); - String headerString = Localization.getString(Strings.Info_Print_Header, project.getRef().getName(), page + 1); + String headerString = Localization.getString(Strings.Info_Print_Header, project.getProjectReference().getName(), page + 1); header.appendText(headerString); header.setStyle("text-align: center;"); body.appendChild(header); @@ -92,7 +93,7 @@ public class PrintDialog extends ViewController { table.setStyle("border:1px solid black;border-collapse:collapse;"); ProjectSettings settings = project.getSettings(); - int i = page * settings.getRows() * settings.getColumns(); + int i = 0; for (int y = 0; y < settings.getRows(); y++) { Tr tr = new Tr(); @@ -103,7 +104,7 @@ public class PrintDialog extends ViewController { + "px; padding: 5px; vertical-align: center; text-align: center; min-height: 30px; min-width: 100px;"); Div div = new Div(); div.setStyle("word-break: break-all; white-space: normal;"); - Pad pad = this.project.getPad(i); + Pad pad = this.project.getPad(new PadIndex(i, page)); if (pad.getContent() != null && pad.getContent().isPadLoaded()) div.appendText(pad.getName()); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileViewController.java index afd7641c48aaffa3b3709727e00337758fe041ce..e915ad9846a31a0ad8e58964a95e655f066ef29c 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileViewController.java @@ -98,7 +98,7 @@ public class ProfileViewController extends ViewController implements ChangeListe @FXML private void chooseButtonHandler(ActionEvent event) { ProfileReference ref = profileList.getSelectionModel().getSelectedItem(); - project.getRef().setProfileReference(ref); + project.getProjectReference().setProfileReference(ref); try { Profile.load(ref); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectExportDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectExportDialog.java index 134b544ce3667fbfe00eb68a4c376a0356897031..213b0699ae137d0f5a4d88e46b7b1f3f8fa6e35f 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectExportDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectExportDialog.java @@ -8,7 +8,7 @@ import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.project.ProjectExporter; import de.tobias.playpad.project.ProjectExporter.ExportView; -import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.Profile; import de.tobias.utils.ui.NotificationHandler; import de.tobias.utils.ui.ViewController; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java index 83bf7d61f216e0d82d8b821a6256251620df9590..91e587b5206c5e48b2e025314f30288d8f73b2db 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java @@ -9,9 +9,9 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; -import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectImporter; -import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileReference; import de.tobias.playpad.viewcontroller.cell.ProjectCell; @@ -118,7 +118,7 @@ public class ProjectManagerDialog extends ViewController implements Notification e.printStackTrace(); } - if (currentProject.getRef().equals(c)) { + if (currentProject.getProjectReference().equals(c)) { deleteButton.setDisable(true); } else { deleteButton.setDisable(false); @@ -223,7 +223,7 @@ public class ProjectManagerDialog extends ViewController implements Notification dialog.getStage().showAndWait(); Project project = dialog.getProject(); - projectList.getItems().add(project.getRef()); + projectList.getItems().add(project.getProjectReference()); } @FXML @@ -267,10 +267,11 @@ public class ProjectManagerDialog extends ViewController implements Notification ProjectReference selectedProject = getSelectedProject(); // Speicher das Aktuelle Projekt erst, damit es in der Exportmethode seperat neu geladen werden kann - if (currentProject.getRef().equals(selectedProject)) { + if (currentProject.getProjectReference().equals(selectedProject)) { try { currentProject.save(); } catch (IOException e) { + // TODO Auto-generated catch block e.printStackTrace(); } } @@ -283,7 +284,7 @@ public class ProjectManagerDialog extends ViewController implements Notification getStage().showAndWait(); if (!cancel) { if (getSelecteItem() != null) { - if (currentProject.getRef() != getSelecteItem()) { + if (currentProject.getProjectReference() != getSelecteItem()) { return Optional.of(getSelecteItem()); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java index 4999837679d1ea9872e13304de64cc5e41647ba1..0b614e0086686b8298b69b88c94fc809c3594ab2 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java @@ -22,6 +22,7 @@ import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.plugin.WindowListener; import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.project.page.PadIndex; import de.tobias.playpad.registry.DefaultRegistry; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.GlobalSettings; @@ -355,7 +356,7 @@ public class MainViewController extends ViewController implements IMainViewContr private void saveProject() { try { - if (openProject.getRef() != null) { + if (openProject.getProjectReference() != null) { openProject.save(); System.out.println("Saved Project: " + openProject); } @@ -464,15 +465,13 @@ public class MainViewController extends ViewController implements IMainViewContr private void addPadsToView() { ProjectSettings settings = openProject.getSettings(); - int index = currentPageShowing * settings.getRows() * settings.getColumns(); for (int i = 0; i < settings.getRows() * settings.getColumns(); i++) { if (padViews.size() > i) { IPadView view = padViews.get(i); - Pad pad = openProject.getPad(index); + Pad pad = openProject.getPad(new PadIndex(i, currentPageShowing)); view.getViewController().setupPad(pad); } - index++; } } @@ -516,7 +515,7 @@ public class MainViewController extends ViewController implements IMainViewContr @Override public void setGlobalVolume(double volume) { if (openProject != null) { - for (Pad pad : openProject.getPads().values()) { + for (Pad pad : openProject.getPads()) { if (pad != null) pad.setMasterVolume(volume); } @@ -558,7 +557,7 @@ public class MainViewController extends ViewController implements IMainViewContr Worker.runLater(() -> { loadMidiDevice(profileSettings.getMidiDevice()); - Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(openProject); + Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(); Platform.runLater(() -> { @@ -672,7 +671,7 @@ public class MainViewController extends ViewController implements IMainViewContr Profile.currentProfile().currentLayout().applyCssMainView(this, getStage(), openProject); } - Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(openProject); + Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(); } /** @@ -698,7 +697,7 @@ public class MainViewController extends ViewController implements IMainViewContr public void updateWindowTitle() { if (openProject != null && Profile.currentProfile() != null) { - getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title, openProject.getRef().getName(), + getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title, openProject.getProjectReference().getName(), Profile.currentProfile().getRef().getName())); } else { getStage().setTitle(Localization.getString(Strings.UI_Window_Main_Title)); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/CartTriggerViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/CartTriggerViewController.java index 5e5f457bb24a08f10381e3c0053fe3ffb2b73482..f8e58620ea32428e1ce48257ee6f460c7bbf1d37 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/CartTriggerViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/CartTriggerViewController.java @@ -1,20 +1,37 @@ package de.tobias.playpad.viewcontroller.option.pad.trigger; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +import org.controlsfx.control.textfield.TextFields; + import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; +import de.tobias.playpad.project.Project; import de.tobias.playpad.trigger.CartTriggerItem; import de.tobias.utils.ui.ContentViewController; +import de.tobias.utils.ui.icon.FontAwesomeType; +import de.tobias.utils.ui.icon.FontIcon; +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.ContentDisplay; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; import javafx.scene.control.TextField; - +import javafx.util.Callback; public class CartTriggerViewController extends ContentViewController { @FXML private ComboBox<PadStatus> statusComboBox; @FXML private CheckBox allCartsCheckbox; @FXML private TextField cartTextField; + @FXML private ListView<UUID> addedCarts; + @FXML private Button addButton; private CartTriggerItem item; @@ -24,7 +41,7 @@ public class CartTriggerViewController extends ContentViewController { statusComboBox.setValue(item.getNewStatus()); allCartsCheckbox.setSelected(item.isAllCarts()); - cartTextField.setText(item.getCartsString()); + addedCarts.getItems().setAll(item.getCarts()); } @Override @@ -34,13 +51,45 @@ public class CartTriggerViewController extends ContentViewController { allCartsCheckbox.selectedProperty().addListener((a, b, c) -> { - cartTextField.setDisable(c); item.setAllCarts(c); }); - cartTextField.textProperty().addListener((a, b, c) -> - { - if (c != null && !c.isEmpty()) - item.setCartsString(c); + + // Auto Complete + Project project = PlayPadMain.getProgramInstance().getCurrentProject(); + Set<String> names = project.getPads().stream().filter(p -> p.getStatus() != PadStatus.EMPTY).map(Pad::getName) + .collect(Collectors.toSet()); + TextFields.bindAutoCompletion(cartTextField, names); + + addedCarts.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() { + + @Override + public ListCell<UUID> call(ListView<UUID> param) { + ListCell<UUID> cell = new ListCell<UUID>() { + protected void updateItem(UUID item, boolean empty) { + super.updateItem(item, empty); + if (!empty) { + setGraphic(new Button("", new FontIcon(FontAwesomeType.TRASH))); + setContentDisplay(ContentDisplay.RIGHT); + Project project = PlayPadMain.getProgramInstance().getCurrentProject(); + setText(project.getPad(item).getName()); + } + } + }; + return cell; + } }); } + + @FXML + private void addHandler(ActionEvent event) { + Project project = PlayPadMain.getProgramInstance().getCurrentProject(); + for (Pad pad : project.getPads()) { + if (pad.getStatus() != PadStatus.EMPTY) { + if (pad.getName().equals(cartTextField.getText())) { + item.getCarts().add(pad.getUuid()); + addedCarts.getItems().add(pad.getUuid()); + } + } + } + } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java index d0585f047370d9990842adf8841c03fa03fe450e..bd24b753b9a6ad7d9ee6cc4e1f2cc16d8d8e8cb4 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java @@ -3,8 +3,8 @@ package de.tobias.playpad.viewcontroller.option.profile; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; -import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.project.Project; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java index f1fe20a9a9946fd2a2b116faa07548bcbdde439a..688b4b0f5e3b80b2b4ca0eb46bf95d4ba14b7685 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java @@ -172,8 +172,7 @@ public class MappingTabViewController extends ProfileSettingsTabViewController i updateTitle(name()); updateProgress(-1, -1); - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(currentProject); + Profile.currentProfile().getMappings().getActiveMapping().adjustPadColorToMapper(); Mapping activeMapping = Profile.currentProfile().getMappings().getActiveMapping(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java index 24fe811955fbb7b5e7e7d5d3d1bc00ec5b09bcfb..05315f5d6a113a20bb838b5f8a0048c0a9fa186f 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java @@ -143,28 +143,6 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController i return changeSettings; } - // @Override - // public void reload(ProjectSettings settings, Project project, IMainViewController controller) { - // Alert alert = new Alert(AlertType.INFORMATION); - // alert.setContentText(Localization.getString(Strings.UI_Window_Settings_Gen_Wait)); - // - // alert.getButtonTypes().clear(); - // alert.initOwner(controller.getStage()); - // alert.initModality(Modality.WINDOW_MODAL); - // Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); - // PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); - // - // alert.show(); - // - // Worker.runLater(() -> - // { - // Platform.runLater(() -> - // { - // - // }); - // }); - // } - @Override public boolean validSettings() { if (screenValid()) { 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 551b2d4cba545afd719ada399446cf3d4b94edae..c5cc0bc29096bc194d8a97511f091eff7274a7b3 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java @@ -122,7 +122,7 @@ public class PathsTabViewController extends ProjectSettingsTabViewController imp project.closeFile(); - for (Pad pad : project.getPads().values()) { + for (Pad pad : project.getPads()) { try { if (pad.getStatus() != PadStatus.EMPTY) { PadContent content = pad.getContent(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java index 6d284bb6d5a013c3a4bdb4fac3ff82cc37c8de99..fe181cae7122c8eaf94e8a1ae7e887434cb03851 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java @@ -7,8 +7,8 @@ import org.controlsfx.control.TaskProgressView; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; -import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.IProjectSettingsViewController; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java index abbbf607050a5f6e31bef72c3a5fabdffb387c21..814032b715b6e22f7c8ba572ae00f3080cbaf32e 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java @@ -13,6 +13,7 @@ import de.tobias.playpad.pad.conntent.PadContentConnect; import de.tobias.playpad.pad.drag.PadDragMode; import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.page.PadIndex; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; @@ -22,6 +23,7 @@ import de.tobias.utils.util.FileUtils; import javafx.scene.SnapshotParameters; import javafx.scene.image.WritableImage; import javafx.scene.input.ClipboardContent; +import javafx.scene.input.DataFormat; import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.scene.input.MouseEvent; @@ -31,7 +33,6 @@ import javafx.scene.paint.Color; public class PadDragListener { - private static final String REGEX = "[0-9]+"; private Pad sourcePad; final private Pane view; @@ -41,6 +42,8 @@ public class PadDragListener { private PadDragOptionView padHud; private FileDragOptionView fileHud; + private static DataFormat dataFormat = new DataFormat("de.tobias.playpad.padindex"); + public PadDragListener(Pad pad, IPadView view) { this.sourcePad = pad; this.view = view.getRootNode(); @@ -91,9 +94,9 @@ public class PadDragListener { } // Drag and Drop von Pads - if (event.getDragboard().hasString() && event.getDragboard().getString().trim().matches(REGEX)) { - int padID = Integer.valueOf(event.getDragboard().getString()); - if (padID != sourcePad.getIndex()) { + if (event.getDragboard().hasContent(dataFormat)) { + PadIndex index = (PadIndex) event.getDragboard().getContent(dataFormat); // TODO Check cast + if (!sourcePad.getPadIndex().equals(index)) { Collection<PadDragMode> connects = PlayPadPlugin.getRegistryCollection().getDragModes().getComponents(); @@ -150,11 +153,12 @@ public class PadDragListener { } } - if (db.hasString() && db.getString().matches(REGEX)) { - int padID = Integer.valueOf(db.getString()); + if (db.hasContent(dataFormat)) { + PadIndex padID = (PadIndex) db.getContent(dataFormat); // TODO Check Cast PadDragMode mode = padHud.getSelectedPadDragMode(); - mode.handle(padID, sourcePad.getIndex(), project); + + mode.handle(padID, sourcePad.getPadIndex(), project); padHud.hide(); PlayPadPlugin.getImplementation().getMainViewController() @@ -191,7 +195,7 @@ public class PadDragListener { dragboard.setDragView(snapshot); ClipboardContent content = new ClipboardContent(); - content.putString(String.valueOf(sourcePad.getIndex())); + content.put(dataFormat, sourcePad.getPadIndex()); dragboard.setContent(content); event.consume(); diff --git a/PlayWallCore/src/de/tobias/playpad/PlayPadPlugin.java b/PlayWallCore/src/de/tobias/playpad/PlayPadPlugin.java index cdd076538f46abdcba1c2e01db8c252360a0723d..3be32345e43b267c3dab88f8e86a2dd4370e7d17 100644 --- a/PlayWallCore/src/de/tobias/playpad/PlayPadPlugin.java +++ b/PlayWallCore/src/de/tobias/playpad/PlayPadPlugin.java @@ -1,14 +1,10 @@ package de.tobias.playpad; -import de.tobias.playpad.project.Project; - public final class PlayPadPlugin { private static PlayPad implementation; private static RegistryCollection registryCollection; - private Project currentProject; - public static PlayPad getImplementation() { return implementation; } @@ -29,8 +25,4 @@ public final class PlayPadPlugin { protected static void setRegistryCollection(RegistryCollection registryCollection) { PlayPadPlugin.registryCollection = registryCollection; } - - public Project getCurrentproject() { - return currentProject; - } } diff --git a/PlayWallCore/src/de/tobias/playpad/action/Mapping.java b/PlayWallCore/src/de/tobias/playpad/action/Mapping.java index 434731682345ce9d284b5199e0a180e1f16e7385..60688949f3462b2c15d93090150963d05d607299 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/Mapping.java +++ b/PlayWallCore/src/de/tobias/playpad/action/Mapping.java @@ -161,8 +161,8 @@ public class Mapping implements Cloneable, ActionDisplayable { getActions().forEach(action -> action.clearFeedback()); } - public void adjustPadColorToMapper(Project project) { - ColorAdjuster.applyColorsToMappers(project); + public void adjustPadColorToMapper() { + ColorAdjuster.applyColorsToMappers(); } @Override diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java index 8ca7614c0f368ead082b85c0be15a16c330e9379..301578f1bec761e09dcac3f463303e70a776a481 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java @@ -9,7 +9,6 @@ import de.tobias.playpad.design.CartDesign; import de.tobias.playpad.design.DesignColorAssociator; import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; @@ -21,7 +20,8 @@ import javafx.scene.paint.Paint; * * @since 5.1.0 * - * @see ColorAdjustable Action muss dieses Interface dafür Implementieren, damit die Farbe Automatisch zum pad gemacht wird. + * @see ColorAdjustable Action muss dieses Interface dafür Implementieren, damit die Farbe Automatisch zum pad gemacht + * wird. * @see ColorAssociator Mapper muss dieses Interface implemetieren, damit die entsprechenden Farbe gefunden werden kann * */ @@ -29,11 +29,8 @@ public class ColorAdjuster { /** * Übernimmt die Farben des Pads und den verknüpften Aktionen zu einem Pad auf die Mapper. - * - * @param project - * Aktuelles Projekt. */ - public static void applyColorsToMappers(Project project) { + public static void applyColorsToMappers() { // Apply Layout to Mapper Set<Action> actions = Profile.currentProfile().getMappings().getActiveMapping().getActions(); for (Action action : actions) { @@ -42,7 +39,7 @@ public class ColorAdjuster { if (adjustable.isAutoFeedbackColors()) { for (Mapper mapper : action.getMappers()) { if (mapper instanceof MapperFeedbackable) { - mapColorForMapper(adjustable, mapper, project); + mapColorForMapper(adjustable, mapper); } } } @@ -52,7 +49,7 @@ public class ColorAdjuster { // COMMENT ColorAdjuster - private static void mapColorForMapper(ColorAdjustable cartAction, Mapper mapper, Project project) { + private static void mapColorForMapper(ColorAdjustable cartAction, Mapper mapper) { MapperFeedbackable feedbackable = (MapperFeedbackable) mapper; if (feedbackable.supportFeedback() && mapper instanceof ColorAssociator) { ColorAssociator colorAssociator = (ColorAssociator) mapper; diff --git a/PlayWallCore/src/de/tobias/playpad/pad/Pad.java b/PlayWallCore/src/de/tobias/playpad/pad/Pad.java index 33993d3376e81ec3c9febde2ab568e1732b7496f..2acbc96a6684b83dda1a246462a41d6eb23e69d7 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/Pad.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/Pad.java @@ -1,6 +1,7 @@ package de.tobias.playpad.pad; import java.nio.file.Path; +import java.util.UUID; import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.pad.conntent.play.Pauseable; @@ -9,6 +10,7 @@ import de.tobias.playpad.pad.listener.trigger.PadTriggerDurationListener; import de.tobias.playpad.pad.listener.trigger.PadTriggerStatusListener; import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.page.PadIndex; import de.tobias.playpad.registry.NoSuchComponentException; import javafx.beans.property.DoubleProperty; import javafx.beans.property.IntegerProperty; @@ -23,7 +25,10 @@ import javafx.beans.property.StringProperty; public class Pad { // Verwaltung + private UUID uuid; private IntegerProperty indexProperty = new SimpleIntegerProperty(); + private IntegerProperty pageProperty = new SimpleIntegerProperty(); + private StringProperty nameProperty = new SimpleStringProperty(); private ObjectProperty<PadStatus> statusProperty = new SimpleObjectProperty<>(PadStatus.EMPTY); @@ -47,20 +52,23 @@ public class Pad { // Utils private transient boolean eof; + private transient IPadViewController controller; private transient Project project; public Pad(Project project) { this.project = project; - padSettings = new PadSettings(); + this.uuid = UUID.randomUUID(); + this.padSettings = new PadSettings(); initPadListener(); // Update Trigger ist nicht notwendig, da es in load(Element) ausgerufen wird } - public Pad(Project project, int index) { + public Pad(Project project, int index, int page) { this.project = project; - padSettings = new PadSettings(); + this.uuid = UUID.randomUUID(); + this.padSettings = new PadSettings(); setIndex(index); setStatus(PadStatus.EMPTY); @@ -69,8 +77,12 @@ public class Pad { padSettings.updateTrigger(); } - public Pad(Project project, int index, String name, PadContent content) { - this(project, index); + public Pad(Project project, PadIndex index) { + this(project, index.getId(), index.getPage()); + } + + public Pad(Project project, int index, int page, String name, PadContent content) { + this(project, index, page); setName(name); setContent(content); } @@ -95,6 +107,18 @@ public class Pad { return indexProperty.get(); } + public UUID getUuid() { + return uuid; + } + + void setUuid(UUID uuid) { + this.uuid = uuid; + } + + public int getPage() { + return pageProperty.get(); + } + public int getIndexReadable() { return indexProperty.get() + 1; } @@ -107,6 +131,14 @@ public class Pad { return indexProperty; } + public void setPage(int page) { + pageProperty.set(page); + } + + public PadIndex getPadIndex() { + return new PadIndex(getIndex(), getPage()); + } + public String getName() { return nameProperty.get(); } @@ -187,22 +219,6 @@ public class Pad { contentProperty.get().loadMedia(); } - public void throwException(Path path, Exception exception) { - if (project != null) - project.addException(this, path, exception); - setStatus(PadStatus.ERROR); - } - - public void removeExceptionsForPad() { - if (project != null) - project.removeExceptions(this); - } - - public void removeException(PadException exception) { - if (project != null) - project.removeException(exception); - } - public PadTriggerDurationListener getPadTriggerDurationListener() { return padTriggerDurationListener; } @@ -239,10 +255,26 @@ public class Pad { setStatus(PadStatus.EMPTY); if (project != null) { - project.removeExceptions(this); + // TODO Remove Exceptions refer to pad } } + public void throwException(Path path, Exception exception) { + if (project != null) + project.addException(this, path, exception); + setStatus(PadStatus.ERROR); + } + + public void removeExceptionsForPad() { + if (project != null) + project.removeExceptions(this); + } + + public void removeException(PadException exception) { + if (project != null) + project.removeException(exception); + } + @Override public String toString() { return "Pad: " + indexProperty.get() + " - " + nameProperty.get(); diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java index b17681ae4f70b0f907b8c84b34dc113d70f3658f..bb759b53ca3f33e560cedb1514111f8749500151 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadSerializer.java @@ -1,5 +1,7 @@ package de.tobias.playpad.pad; +import java.util.UUID; + import org.dom4j.Element; import de.tobias.playpad.PlayPadPlugin; @@ -21,6 +23,7 @@ import de.tobias.utils.xml.XMLSerializer; public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { + private static final String UUID_ATTR = "uuid"; private static final String INDEX_ATTR = "index"; private static final String NAME_ATTR = "name"; private static final String STATUS_ATTR = "status"; @@ -44,19 +47,21 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { public static final String CONTENT_ELEMENT = "Content"; private static final String CONTENT_TYPE_ATTR = "type"; - // TODO Remove project var private Project project; public PadSerializer(Project project) { this.project = project; } - public PadSerializer() {} + public PadSerializer() { + } @Override public Pad loadElement(Element element) { Pad pad = new Pad(project); + if (element.attributeValue(UUID_ATTR) != null) + pad.setUuid(UUID.fromString(element.attributeValue(UUID_ATTR))); pad.setIndex(Integer.valueOf(element.attributeValue(INDEX_ATTR))); pad.setName(element.attributeValue(NAME_ATTR)); PadStatus status = PadStatus.valueOf(element.attributeValue(STATUS_ATTR)); @@ -143,7 +148,7 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { } catch (NoSuchComponentException e) { // TODO Auto-generated catch block e.printStackTrace(); - pad.throwException(null, e); + // pad.throwException(null, e); TODO Throw exception to user } } @@ -152,6 +157,7 @@ public class PadSerializer implements XMLSerializer<Pad>, XMLDeserializer<Pad> { @Override public void saveElement(Element element, Pad data) { + element.addAttribute(UUID_ATTR, data.getUuid().toString()); element.addAttribute(INDEX_ATTR, String.valueOf(data.getIndex())); element.addAttribute(NAME_ATTR, data.getName()); if (data.getStatus() == PadStatus.EMPTY || data.getStatus() == PadStatus.ERROR) { diff --git a/PlayWallCore/src/de/tobias/playpad/pad/drag/PadDragMode.java b/PlayWallCore/src/de/tobias/playpad/pad/drag/PadDragMode.java index 3637295c68de51794e91e3fc822d1498d471909b..3a71578f8a5a6e393b8a6db2a51edbe462bb582d 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/drag/PadDragMode.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/drag/PadDragMode.java @@ -2,12 +2,20 @@ package de.tobias.playpad.pad.drag; import de.tobias.playpad.Displayable; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.page.PadIndex; +/** + * Modus um ein Pad mit Drag and Drop zu verschieben. + * + * @author tobias + * + * @since 6.0.0 + */ public abstract class PadDragMode implements Displayable, Comparable<PadDragMode> { public abstract String getType(); - public abstract void handle(int oldPad, int newPad, Project project); + public abstract void handle(PadIndex oldPad, PadIndex newPad, Project project); @Override public int compareTo(PadDragMode o) { diff --git a/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerStatusListener.java b/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerStatusListener.java index 0bb27b286d84c52286513d028a82c93e40b65b36..83f168dc289032378a4838c6e326f9f037d7a8f9 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerStatusListener.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/listener/trigger/PadTriggerStatusListener.java @@ -24,11 +24,11 @@ public class PadTriggerStatusListener implements ChangeListener<PadStatus> { public void changed(ObservableValue<? extends PadStatus> observable, PadStatus oldValue, PadStatus newValue) { if (!pad.isIgnoreTrigger()) { PadSettings padSettings = pad.getPadSettings(); - + // Execute Trigger if (newValue == PadStatus.PLAY) { // TRIGGER FÜR START executeTrigger(padSettings.getTriggers().get(TriggerPoint.START)); - } else if (newValue == PadStatus.STOP) { // TRIGGER FÜR STOP + } else if (newValue == PadStatus.STOP || (oldValue == PadStatus.PLAY && newValue == PadStatus.READY)) { // TRIGGER FÜR STOP executeTrigger(padSettings.getTriggers().get(TriggerPoint.EOF_STOP)); } else if (oldValue == PadStatus.PLAY && newValue == PadStatus.READY && pad.isEof()) { // TRIGGER FÜR EOF executeTrigger(padSettings.getTriggers().get(TriggerPoint.EOF_STOP)); diff --git a/PlayWallCore/src/de/tobias/playpad/project/Project.java b/PlayWallCore/src/de/tobias/playpad/project/Project.java index 10b45bc009216506f6e2fbda522e74ca48fd5178..f9ed58b8cf90b99fdff729996220fc5296a00b56 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/Project.java +++ b/PlayWallCore/src/de/tobias/playpad/project/Project.java @@ -3,18 +3,26 @@ package de.tobias.playpad.project; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.UUID; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.DocumentHelper; import org.dom4j.Element; +import org.dom4j.io.SAXReader; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadException; -import de.tobias.playpad.pad.PadSerializer; +import de.tobias.playpad.pad.PadStatus; +import de.tobias.playpad.project.page.PadIndex; +import de.tobias.playpad.project.page.Page; +import de.tobias.playpad.project.page.PageSerializer; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileNotFoundException; @@ -27,125 +35,115 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; /** - * Hold all information about the pads and it's settings. + * Verwaltet alle Seiten, die jeweils die Kacheln enthalten. * * @author tobias * + * @since 6.0.0 */ public class Project { /** * Pattern für den Namen des Projekts */ - public static final String PROJECT_NAME_PATTERN = "[\\p{L},0-9]{1}[\\p{L}\\s-_]{0,}"; + public static final String PROJECT_NAME_PATTERN = "\\w{1}[\\w\\s-_]{0,}"; /** * Dateiendung für eine projekt Datei */ public static final String FILE_EXTENSION = ".xml"; - /** - * Die projektreferenz gibt auskunft über den Namen und die UUID des Projektes - */ - private ProjectReference ref; - /** - * Liste mit allen Pads. - */ - private HashMap<Integer, Pad> pads; + private final HashMap<Integer, Page> pages; + private final ProjectReference projectReference; private ProjectSettings settings; - + /** * Liste mit den aktuellen Laufzeitfehlern. */ private transient ObservableList<PadException> exceptions; - private transient IntegerProperty activePlayers; - /** - * Erstellt ein neues leeres Projekt mit einer Referenz. - * - * @param ref - * Referenz mit Namen des Projekts. - */ public Project(ProjectReference ref) { - this.ref = ref; - this.pads = new HashMap<>(); + this.projectReference = ref; + this.pages = new HashMap<>(); this.settings = new ProjectSettings(); - + this.exceptions = FXCollections.observableArrayList(); this.activePlayers = new SimpleIntegerProperty(); } - /** - * Gibt die Projekt Referenz zurück. Dazu zählen Name und UUID sowie das zugehörige Profile. - * - * @return Referenz. - */ - public ProjectReference getRef() { - return ref; + public ProjectSettings getSettings() { + return settings; } - // TODO Update in 5.1.0 - /** - * Gibt ein Pad an einem Index zurück. Sollte kein pad vorhanden sein (weil null, so wird vorher ein neues erzeugt.) - * - * @param index - * Index - * @return Pad am Index i - */ - public Pad getPad(int index) { - if (!pads.containsKey(index)) { - addPadForIndex(index); - } - return pads.get(index); + public ProjectReference getProjectReference() { + return projectReference; + } + + public long getPlayedPlayers() { + return getPads().stream().filter(p -> p.getStatus() == PadStatus.PLAY || p.getStatus() == PadStatus.PAUSE).count(); + } + + public boolean hasPlayedPlayers() { + return getPlayedPlayers() != 0; } public Pad getPad(int x, int y, int page) { - if (x < settings.getColumns() && y < settings.getRows() && page < settings.getPageCount()) { - int id = (y * settings.getColumns() + x) + page * settings.getColumns() * settings.getRows(); - return getPad(id); + return getPage(page).getPad(x, y); + } + + public Pad getPad(PadIndex index) { + Page page = pages.get(index.getPage()); + return page.getPad(index.getId()); + } + + public Pad getPad(UUID uuid) { + for (Page page : pages.values()) { + for (Pad pad : page.getPads()) { + if (pad.getUuid().equals(uuid)) { + return pad; + } + } } return null; } - /** - * Gibt die Settings des Projectes zurück - * - * @return - */ - public ProjectSettings getSettings() { - return settings; + public void setPad(PadIndex index, Pad pad) { + if (pad.getPage() != index.getPage()) { + Page oldPage = getPage(pad.getPage()); + oldPage.removePade(index.getId()); + } + Page page = pages.get(index.getPage()); + page.setPad(index.getId(), pad); } - /** - * Erstellt ein neues leeres Pad (mit Referenz zu diesem Projekt) am Index i. - * - * @param index - * Index i - */ - private void addPadForIndex(int index) { - pads.put(index, new Pad(this, index)); + public Collection<Pad> getPads() { + List<Pad> pads = new ArrayList<>(); + pages.values().stream().map(page -> page.getPads()).forEach(pads::addAll); + return pads; } - /** - * Ersetz ein Pad an einem Index i. - * - * @param index - * Index i - * @param pad - * Neues Pad für den Index i - */ - public void setPad(int index, Pad pad) { - pad.setIndex(index); - pads.put(index, pad); + // Pages + + public Page getPage(int index) { + if (!pages.containsKey(index) && index < settings.getPageCount()) { + pages.put(index, new Page(index, this)); + } + return pages.get(index); } - /* - * Speichern und Laden - */ + public Collection<Page> getPages() { + return pages.values(); + } + + public void setPage(int index, Page page) { + pages.put(index, page); + page.setId(index); + } private static final String ROOT_ELEMENT = "Project"; - protected static final String PAD_ELEMENT = "Pad"; + public static final String PAGE_ELEMENT = "Page"; + public static final String PAD_ELEMENT = "Pad"; private static final String SETTINGS_ELEMENT = "Settings"; public static Project load(ProjectReference ref, boolean loadMedia, ProfileChooseable profileChooseable) @@ -154,30 +152,38 @@ public class Project { if (Files.exists(projectPath)) { if (ref.getProfileReference() != null) { - Profile.load(ref.getProfileReference()); // Lädt das entsprechende Profile und aktiviert es + // Lädt das entsprechende Profile und aktiviert es + Profile.load(ref.getProfileReference()); } else { - Profile profile = profileChooseable.getUnkownProfile(); // Lädt Profile / Erstellt neues und hat es - // gleich im Speicher + // Lädt Profile / Erstellt neues und hat es gleich im Speicher + Profile profile = profileChooseable.getUnkownProfile(); ref.setProfileReference(profile.getRef()); } - Project project = new Project(ref); + SAXReader reader = new SAXReader(); + Document document = reader.read(Files.newInputStream(projectPath)); + Element rootElement = document.getRootElement(); - // Lädt Pads - XMLHandler<Pad> handler = new XMLHandler<>(projectPath); - List<Pad> pads = handler.loadElements(PAD_ELEMENT, new PadSerializer(project)); + Project project = new Project(ref); - for (Pad pad : pads) { - if (loadMedia) - pad.loadContent(); - project.pads.put(pad.getIndex(), pad); + // Lädt die Pages und somti auch die Pages + XMLHandler<Page> handler = new XMLHandler<>(rootElement); + List<Page> pages = handler.loadElements(PAGE_ELEMENT, new PageSerializer(project)); + for (Page page : pages) { + project.pages.put(page.getId(), page); } // Lädt die Einstellungen - Element settingsElement = handler.getRootElement().element(SETTINGS_ELEMENT); + Element settingsElement = rootElement.element(SETTINGS_ELEMENT); if (settingsElement != null) project.settings = ProjectSettings.load(settingsElement); + // TODO Externalize, damit beim Start user feedback verbessert wird. + for (Pad pad : project.getPads()) { + if (loadMedia) + pad.loadContent(); + } + return project; } else { throw new ProjectNotFoundException(ref); @@ -185,14 +191,14 @@ public class Project { } public void save() throws IOException { - Path projectPath = ref.getProjectPath(); + Path projectPath = projectReference.getProjectPath(); Document document = DocumentHelper.createDocument(); Element rootElement = document.addElement(ROOT_ELEMENT); // Speichern der Pads - XMLHandler<Pad> handler = new XMLHandler<>(rootElement); - handler.saveElements(PAD_ELEMENT, pads.values(), new PadSerializer()); + XMLHandler<Page> handler = new XMLHandler<>(rootElement); + handler.saveElements(PAGE_ELEMENT, pages.values(), new PageSerializer()); // Speichern der Settings Element settingsElement = rootElement.addElement(SETTINGS_ELEMENT); @@ -205,10 +211,6 @@ public class Project { XMLHandler.save(projectPath, document); } - public HashMap<Integer, Pad> getPads() { - return pads; - } - public int getActivePlayers() { return activePlayers.get(); } @@ -265,10 +267,10 @@ public class Project { public ObservableList<PadException> getExceptions() { return exceptions; } - - // Load Methods + + // Utils public void loadPadsContent() { - getPads().values().forEach(pad -> + getPads().forEach(pad -> { try { pad.loadContent(); @@ -281,15 +283,11 @@ public class Project { @Override public String toString() { - return ref.getName() + " (" + ref.getUuid() + ")"; - } - - public int getPadCount() { - return pads.size(); + return projectReference.getName() + " (" + projectReference.getUuid() + ")"; } public void closeFile() { - pads.values().forEach(pad -> + getPads().forEach(pad -> { if (pad.getContent() != null) pad.getContent().unloadMedia(); diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectExporter.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectExporter.java index 756c508a2f5e922ea8609f02905b295ce50d2456..3fe6c2e24409a8cdf02e4868f4f62a9f8bcadc5d 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectExporter.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectExporter.java @@ -16,6 +16,7 @@ import org.dom4j.io.XMLWriter; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadSerializer; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.ProfileReference; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectImporter.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectImporter.java index 57ebef70dc69976a9c3c1c20afd0c11549659e30..372fe52fa7301e6bee4163c1e38aabc5bd9e51ed 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectImporter.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectImporter.java @@ -16,6 +16,7 @@ import org.dom4j.io.XMLWriter; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadSerializer; +import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileReference; import de.tobias.utils.application.App; diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectNotFoundException.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectNotFoundException.java index ae80b4f021bb642ac7388cc72051ae26ba901051..49f97343e35713cfc8d67aede79bed34c896abfd 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectNotFoundException.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectNotFoundException.java @@ -1,5 +1,7 @@ package de.tobias.playpad.project; +import de.tobias.playpad.project.ref.ProjectReference; + public class ProjectNotFoundException extends Exception { private static final long serialVersionUID = 1L; diff --git a/PlayWallCore/src/de/tobias/playpad/project/page/PadIndex.java b/PlayWallCore/src/de/tobias/playpad/project/page/PadIndex.java new file mode 100644 index 0000000000000000000000000000000000000000..11067feea3e89e1eba4e4aafa1fa5193ad800a3a --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/project/page/PadIndex.java @@ -0,0 +1,62 @@ +package de.tobias.playpad.project.page; + +import java.io.Serializable; + +/** + * Struktur um den Index eines Pads zu beschrieben. + * + * @author tobias + * + * @since 6.0.0 + */ +public class PadIndex implements Serializable { + + private static final long serialVersionUID = 2026743397726990321L; + + private final int id; + private final int page; + + public PadIndex(int id, int page) { + this.id = id; + this.page = page; + } + + public int getId() { + return id; + } + + public int getPage() { + return page; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + id; + result = prime * result + page; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PadIndex other = (PadIndex) obj; + if (id != other.id) + return false; + if (page != other.page) + return false; + return true; + } + + @Override + public String toString() { + return "PadIndex [id=" + id + ", page=" + page + "]"; + } + +} diff --git a/PlayWallCore/src/de/tobias/playpad/project/page/Page.java b/PlayWallCore/src/de/tobias/playpad/project/page/Page.java new file mode 100644 index 0000000000000000000000000000000000000000..c76eac00f33a56d775cd744909c641109b1e5be9 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/project/page/Page.java @@ -0,0 +1,89 @@ +package de.tobias.playpad.project.page; + +import java.util.Collection; +import java.util.HashMap; + +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectSettings; + +/** + * + * @author tobias + * + * @since 6.0.0 + */ +public class Page { + + private int id; + private String name; + private HashMap<Integer, Pad> pads; + + private transient Project projectReference; + + public Page(int id, Project reference) { + this.id = id; + this.name = ""; + this.pads = new HashMap<>(); + + this.projectReference = reference; + } + + public Page(int id, String name, Project reference) { + this.id = id; + this.name = name; + this.pads = new HashMap<>(); + + this.projectReference = reference; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Project getProjectReference() { + return projectReference; + } + + public Pad getPad(int id) { + if (!pads.containsKey(id)) { + // Create new pad for id + setPad(id, new Pad(projectReference, id, this.id)); + } + return pads.get(id); + } + + public Pad getPad(int x, int y) { + ProjectSettings settings = projectReference.getSettings(); + if (x < settings.getColumns() && y < settings.getRows()) { + int id = y * settings.getColumns() + x; + return getPad(id); + } + return null; + } + + public void setPad(int id, Pad pad) { + pads.put(id, pad); + pad.setIndex(id); + } + + public Collection<Pad> getPads() { + return pads.values(); + } + + public void removePade(int id) { + pads.remove(id); + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/project/page/PageSerializer.java b/PlayWallCore/src/de/tobias/playpad/project/page/PageSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..52807e5288b6c0fc60e4bfa3aff34cba3806f2e8 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/project/page/PageSerializer.java @@ -0,0 +1,62 @@ +package de.tobias.playpad.project.page; + +import java.util.List; + +import org.dom4j.Element; + +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSerializer; +import de.tobias.playpad.project.Project; +import de.tobias.utils.xml.XMLDeserializer; +import de.tobias.utils.xml.XMLHandler; +import de.tobias.utils.xml.XMLSerializer; + +public class PageSerializer implements XMLSerializer<Page>, XMLDeserializer<Page> { + + private static final String ID_ATTR = "id"; + private static final String NAME_ATTR = "name"; + + private Project project; + + /** + * Für Serilize + */ + public PageSerializer() { + } + + /** + * Für Deserialize + * + * @param project + * Project Reference + */ + public PageSerializer(Project project) { + this.project = project; + } + + @Override + public Page loadElement(Element element) { + int id = Integer.valueOf(element.attributeValue(ID_ATTR)); + String name = element.attributeValue(NAME_ATTR); + + XMLHandler<Pad> handler = new XMLHandler<>(element); + List<Pad> pads = handler.loadElements(Project.PAD_ELEMENT, new PadSerializer(project)); + + Page page = new Page(id, name, project); + for (Pad pad : pads) { + pad.setPage(id); + page.setPad(pad.getIndex(), pad); + } + + return page; + } + + @Override + public void saveElement(Element newElement, Page data) { + newElement.addAttribute(ID_ATTR, String.valueOf(data.getId())); + newElement.addAttribute(NAME_ATTR, data.getName()); + + XMLHandler<Pad> handler = new XMLHandler<>(newElement); + handler.saveElements(Project.PAD_ELEMENT, data.getPads(), new PadSerializer()); + } +} diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectReference.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java similarity index 97% rename from PlayWallCore/src/de/tobias/playpad/project/ProjectReference.java rename to PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java index eb7855d0a5e04341fd69d46ad86f607cd11027b8..84a48da72ee17c68881e98eedf22671af4846ccd 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectReference.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReference.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.project; +package de.tobias.playpad.project.ref; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -15,6 +15,7 @@ import org.dom4j.DocumentHelper; import org.dom4j.Element; import de.tobias.playpad.Displayable; +import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.ProfileReference; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; @@ -125,8 +126,8 @@ public class ProjectReference implements Displayable { } private static void duplicateFiles(ProjectReference currentProject, ProjectReference newProjectReference) throws IOException { - Path oldPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, currentProject.getFileName()); - Path newPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, newProjectReference.getFileName()); + Path oldPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, currentProject.getName()); + Path newPath = ApplicationUtils.getApplication().getPath(PathType.DOCUMENTS, newProjectReference.getName()); Files.copy(oldPath, newPath, StandardCopyOption.COPY_ATTRIBUTES); } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceList.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceList.java similarity index 58% rename from PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceList.java rename to PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceList.java index a9a172d9097d6b2646fefd35b3084a34fada0123..b576c519c8bd5842f84996cc5d2e9a1e4e9c38a4 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceList.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceList.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.project; +package de.tobias.playpad.project.ref; import de.tobias.utils.list.UniqList; @@ -16,22 +16,19 @@ final class ProjectReferenceList extends UniqList<ProjectReference> { public boolean contains(Object o) { if (o instanceof String) { - for (ProjectReference item : this) { - if (item.getName().equals(o)) { + for (ProjectReference reference : this) { + if (reference.getName().equals(o)) { return true; - } else if (item.toString().equals(o)) { + } else if (reference.toString().equals(o)) { return true; } } } else if (o instanceof ProjectReference) { - for (ProjectReference item : this) { - if (item.getName() == o) { + for (ProjectReference reference : this) { + if (reference.getName() == o) { + return true; + } else if (reference.getName().equals(((ProjectReference) o).getName())) { // TODO Check return true; - } else { - ProjectReference projectRef = (ProjectReference) o; - if (item.getName().equals(projectRef.getName())) { - return true; - } } } } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceSerializer.java b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java similarity index 97% rename from PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceSerializer.java rename to PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java index d84647a222b939b027293012b12b1fed3044b52a..3d6996db4d8f5fc1a73a8da8a1cf446a3b267897 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectReferenceSerializer.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ref/ProjectReferenceSerializer.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.project; +package de.tobias.playpad.project.ref; import java.io.IOException; import java.nio.file.Files; diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java index 0f4b33e9383b26ce94cae26baf12f54670534fe2..8bbc1d2b26b89637ddbb4243fed361595c3905dc 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java @@ -2,8 +2,8 @@ package de.tobias.playpad.viewcontroller.option; import java.util.ResourceBundle; -import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; +import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.ui.ContentViewController; diff --git a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/stopaction/StopAction.java b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/stopaction/StopAction.java index b417358e2a044cc8940383a012d45127d50b6c5b..cc77ec62a7a5cb1d1cf4f1c3df4645e4a57cd353 100644 --- a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/stopaction/StopAction.java +++ b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/stopaction/StopAction.java @@ -27,7 +27,7 @@ public class StopAction extends Action { @Override public void performAction(InputType type, Project project, IMainViewController mainViewController) { - for (Pad pad : project.getPads().values()) { + for (Pad pad : project.getPads()) { if (pad.getStatus() == PadStatus.PLAY || pad.getStatus() == PadStatus.PAUSE) pad.setStatus(PadStatus.STOP, true); } diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java index 9c310081e55225e2ea8fd37d05ddd2526ef9c891..9472dff4c3dfe81747d58cd9987ac5ac01871177 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/image/ImageContent.java @@ -74,7 +74,7 @@ public class ImageContent extends PadContent { if (Files.exists(path)) { getPad().setStatus(PadStatus.READY); } else { - getPad().throwException(path, new FileNotFoundException()); + // getPad().throwException(path, new FileNotFoundException()); TODO Error Handling User } } diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java index d3451a5e691f47b44b6fc4d628be9cc9ef9f3c64..69ab186cec6a0db0cbf54f99bef470613dac3f19 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java @@ -124,7 +124,7 @@ public class MediaSettingsTabViewController extends ProfileSettingsTabViewContro public boolean validSettings() { return true; } - + @Override public Task<Void> getTask(ProfileSettings settings, Project project, IMainViewController controller) { return new Task<Void>() { diff --git a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java index b4a36a3aac7c1defa53feeed5d9985fc40a6292c..cab86a4660c6e35ba74a71cd4bc344ab264dcfa0 100644 --- a/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java +++ b/PlayWallPlugins/mediaplugin/de/tobias/playpad/mediaplugin/video/VideoContent.java @@ -192,7 +192,7 @@ public class VideoContent extends PadContent implements Pauseable, Durationable getPad().getController().getView().showBusyView(false); } }); - getPad().throwException(path, player.getError()); +// getPad().throwException(path, player.getError()); TODO Error Handling User }); player.setOnEndOfMedia(() -> {