From 58ac8664a3ce0ba04d617d519af2ad14bac4c8b5 Mon Sep 17 00:00:00 2001 From: tobias <thinkdifferent055@gmail.com> Date: Fri, 6 Jan 2017 22:56:53 +0100 Subject: [PATCH] Replace ViewController/ContentViewController to NVC in most cases --- .idea/codeStyleSettings.xml | 9 ++++ .../playpad/action/cartaction/CartAction.java | 3 +- .../action/factory/CartActionFactory.java | 14 ++---- .../action/factory/NavigateActionFactory.java | 3 +- .../action/factory/PageActionFactory.java | 3 +- .../playpad/action/mapper/KeyboardMapper.java | 3 +- .../playpad/action/mapper/MidiMapper.java | 3 +- .../DesktopMenuToolbarViewController.java | 25 +++++------ .../desktop/pad/DesktopPadViewController.java | 35 ++++++++------- .../trigger/CartTriggerItemFactory.java | 3 +- .../trigger/VolumeTriggerItemFactory.java | 3 +- .../playpad/viewcontroller/LaunchDialog.java | 34 ++++++++------- ...java => CartActionTypeViewController.java} | 23 ++++------ .../actions/CartActionViewController.java | 5 ++- .../ClassicCartDesignViewController.java | 4 +- .../ClassicGlobalDesignViewController.java | 4 +- .../ModernCartDesignViewController.java | 10 ++--- .../ModernGlobalDesignViewController.java | 10 ++--- .../dialog/DuplicateProfileDialog.java | 5 ++- .../dialog/DuplicateProjectDialog.java | 6 ++- .../viewcontroller/dialog/ImportDialog.java | 10 +++-- .../dialog/NewProfileDialog.java | 38 ++++++++++------ .../dialog/NewProjectDialog.java | 27 ++++++------ .../dialog/PluginViewController.java | 18 ++++---- .../viewcontroller/dialog/PrintDialog.java | 20 +++++---- .../dialog/ProfileChooseDialog.java | 22 ++++++---- .../dialog/ProfileViewController.java | 24 ++++++----- .../dialog/ProjectExportDialog.java | 26 +++++------ .../dialog/ProjectManagerDialog.java | 43 ++++++++++--------- .../viewcontroller/dialog/SaveDialog.java | 2 +- .../mapper/KeyboardMapperViewController.java | 4 +- .../mapper/MidiMapperViewController.java | 7 +-- .../DoubleFeedbackViewController.java | 5 ++- .../SingleFeedbackViewController.java | 5 ++- .../global/GlobalSettingsViewController.java | 27 ++++++------ .../option/global/KeysConflictDialog.java | 2 +- .../option/global/KeysTabViewController.java | 8 ++-- .../global/UpdateTabViewController.java | 8 ++-- .../pad/DesignPadTabViewController.java | 4 +- .../pad/GeneralPadTabViewController.java | 6 +-- .../option/pad/PadSettingsViewController.java | 33 +++++++------- .../option/pad/PathLookupListener.java | 2 +- .../pad/PlayerPadTabViewController.java | 4 +- .../pad/TriggerPadTabViewController.java | 4 +- .../trigger/CartTriggerViewController.java | 5 ++- .../trigger/TriggerPointViewController.java | 13 +++--- .../trigger/TriggerTimeViewController.java | 11 +++-- .../trigger/VolumeTriggerViewController.java | 5 ++- .../profile/AudioTabViewController.java | 2 +- .../profile/DesignTabViewController.java | 4 +- .../profile/GeneralTabViewController.java | 4 +- .../profile/MappingTabViewController.java | 21 ++++----- .../option/profile/MidiTabViewController.java | 4 +- .../profile/PlayerTabViewController.java | 4 +- .../ProfileSettingsViewController.java | 25 +++++------ .../project/GeneralTabViewController.java | 4 +- .../project/PathsTabViewController.java | 6 +-- .../ProjectSettingsViewController.java | 27 ++++++------ .../settings/FadeViewController.java | 5 ++- .../WarningFeedbackViewController.java | 7 +-- .../src/de/tobias/playpad/Displayable.java | 7 +-- .../playpad/action/ActionDisplayable.java | 3 +- .../action/mapper/MapperViewController.java | 7 +-- .../playpad/tigger/TriggerItemFactory.java | 3 +- .../CartDesignViewController.java | 7 +-- .../GlobalDesignViewController.java | 7 +-- .../PadSettingsTabViewController.java | 10 ++--- .../GlobalSettingsTabViewController.java | 30 +++++-------- .../ProfileSettingsTabViewController.java | 34 ++++++--------- .../ProjectSettingsTabViewController.java | 36 ++++++---------- .../impl/MediaSettingsTabViewController.java | 2 +- .../VideoPadSettingsTabViewController.java | 4 +- 72 files changed, 430 insertions(+), 421 deletions(-) create mode 100644 .idea/codeStyleSettings.xml rename PlayWall/src/de/tobias/playpad/viewcontroller/actions/{CartActionsViewController.java => CartActionTypeViewController.java} (88%) diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml new file mode 100644 index 00000000..c4c95431 --- /dev/null +++ b/.idea/codeStyleSettings.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectCodeStyleSettingsManager"> + <option name="PER_PROJECT_SETTINGS"> + <value /> + </option> + <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" /> + </component> +</project> \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java b/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java index e6d780ac..64cd7d2e 100644 --- a/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java +++ b/PlayWall/src/de/tobias/playpad/action/cartaction/CartAction.java @@ -1,5 +1,6 @@ package de.tobias.playpad.action.cartaction; +import de.tobias.utils.nui.NVC; import org.dom4j.Element; import de.tobias.playpad.Strings; @@ -260,7 +261,7 @@ public class CartAction extends Action implements ColorAdjustable { private static CartActionViewController cartActionViewController; @Override - public ContentViewController getSettingsViewController() { + public NVC getSettingsViewController() { if (cartActionViewController == null) { cartActionViewController = new CartActionViewController(); } diff --git a/PlayWall/src/de/tobias/playpad/action/factory/CartActionFactory.java b/PlayWall/src/de/tobias/playpad/action/factory/CartActionFactory.java index 48b84f17..b85d01c3 100644 --- a/PlayWall/src/de/tobias/playpad/action/factory/CartActionFactory.java +++ b/PlayWall/src/de/tobias/playpad/action/factory/CartActionFactory.java @@ -2,7 +2,6 @@ package de.tobias.playpad.action.factory; import java.util.List; -import de.tobias.playpad.Strings; import de.tobias.playpad.action.Action; import de.tobias.playpad.action.ActionFactory; import de.tobias.playpad.action.ActionDisplayable; @@ -13,14 +12,9 @@ import de.tobias.playpad.action.cartaction.CartAction.ControlMode; import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.IMappingTabViewController; -import de.tobias.playpad.viewcontroller.actions.CartActionsViewController; +import de.tobias.playpad.viewcontroller.actions.CartActionTypeViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; -import de.tobias.utils.ui.icon.FontAwesomeType; -import de.tobias.utils.ui.icon.FontIcon; -import de.tobias.utils.util.Localization; -import javafx.beans.property.SimpleStringProperty; -import javafx.beans.property.StringProperty; -import javafx.scene.Node; import javafx.scene.control.TreeItem; public class CartActionFactory extends ActionFactory implements ActionDisplayable { @@ -48,8 +42,8 @@ public class CartActionFactory extends ActionFactory implements ActionDisplayabl // Settings View (Übersicht mit den Buttons). Die Buttons rufen dann die jeweilige CartAction auf. Da muss dann auch die MapperView // manuell gesetzt werden. @Override - public ContentViewController getActionSettingsViewController(Mapping mapping, IMappingTabViewController controller) { - return new CartActionsViewController(mapping, controller); + public NVC getActionSettingsViewController(Mapping mapping, IMappingTabViewController controller) { + return new CartActionTypeViewController(mapping, controller); } @Override diff --git a/PlayWall/src/de/tobias/playpad/action/factory/NavigateActionFactory.java b/PlayWall/src/de/tobias/playpad/action/factory/NavigateActionFactory.java index 34d822e0..ea5f8c1c 100644 --- a/PlayWall/src/de/tobias/playpad/action/factory/NavigateActionFactory.java +++ b/PlayWall/src/de/tobias/playpad/action/factory/NavigateActionFactory.java @@ -11,6 +11,7 @@ import de.tobias.playpad.action.Mapping; import de.tobias.playpad.action.actions.NavigateAction; import de.tobias.playpad.action.actions.NavigateAction.NavigationType; import de.tobias.playpad.settings.Profile; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.ui.icon.MaterialDesignIcon; @@ -52,7 +53,7 @@ public class NavigateActionFactory extends ActionFactory implements ActionDispla } @Override - public ContentViewController getSettingsViewController() { + public NVC getSettingsViewController() { return null; } diff --git a/PlayWall/src/de/tobias/playpad/action/factory/PageActionFactory.java b/PlayWall/src/de/tobias/playpad/action/factory/PageActionFactory.java index d9af8f2a..cf899270 100644 --- a/PlayWall/src/de/tobias/playpad/action/factory/PageActionFactory.java +++ b/PlayWall/src/de/tobias/playpad/action/factory/PageActionFactory.java @@ -11,6 +11,7 @@ import de.tobias.playpad.action.Mapping; import de.tobias.playpad.action.actions.PageAction; import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -55,7 +56,7 @@ public class PageActionFactory extends ActionFactory implements ActionDisplayabl } @Override - public ContentViewController getSettingsViewController() { + public NVC getSettingsViewController() { return null; } diff --git a/PlayWall/src/de/tobias/playpad/action/mapper/KeyboardMapper.java b/PlayWall/src/de/tobias/playpad/action/mapper/KeyboardMapper.java index 04d18be7..fe92eb39 100644 --- a/PlayWall/src/de/tobias/playpad/action/mapper/KeyboardMapper.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/KeyboardMapper.java @@ -1,5 +1,6 @@ package de.tobias.playpad.action.mapper; +import de.tobias.utils.nui.NVC; import org.dom4j.Element; import de.tobias.playpad.Strings; @@ -96,7 +97,7 @@ public class KeyboardMapper extends Mapper { private KeyboardMapperViewController settingsViewController; @Override - public ContentViewController getSettingsViewController() { + public NVC getSettingsViewController() { if (settingsViewController == null) { settingsViewController = new KeyboardMapperViewController(); } diff --git a/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java b/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java index 8a9c9e24..36495afc 100644 --- a/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java @@ -1,6 +1,7 @@ package de.tobias.playpad.action.mapper; import de.tobias.playpad.action.mididevice.MidiDeviceImpl; +import de.tobias.utils.nui.NVC; import org.dom4j.Element; import de.tobias.playpad.Strings; @@ -209,7 +210,7 @@ public class MidiMapper extends Mapper implements ColorAssociator, MapperFeedbac private MidiMapperViewController settingsViewController; @Override - public ContentViewController getSettingsViewController() { + public NVC getSettingsViewController() { if (settingsViewController == null) { settingsViewController = new MidiMapperViewController(); } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index 67e1f160..545fd75f 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -8,6 +8,7 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import de.tobias.utils.nui.NVCStage; import org.controlsfx.control.SegmentedButton; import org.controlsfx.control.textfield.TextFields; @@ -479,7 +480,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro doAction(() -> { NewProjectDialog dialog = new NewProjectDialog(mainViewController.getStage()); - dialog.getStage().showAndWait(); + dialog.getStageContainer().ifPresent(NVCStage::showAndWait); Project project = dialog.getProject(); if (project != null) { @@ -543,7 +544,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro doAction(() -> { ProfileViewController controller = new ProfileViewController(mainViewController.getStage(), openProject); - controller.getStage().showAndWait(); + controller.getStageContainer().ifPresent(NVCStage::showAndWait); mainViewController.updateWindowTitle(); }); } @@ -551,7 +552,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML void printMenuHandler(ActionEvent event) { PrintDialog dialog = new PrintDialog(openProject, mainViewController.getStage()); - dialog.getStage().show(); + dialog.getStageContainer().ifPresent(NVCStage::show); } @FXML @@ -584,7 +585,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro doAction(() -> { PluginViewController controller = new PluginViewController(mainViewController.getStage()); - controller.getStage().showAndWait(); + controller.getStageContainer().ifPresent(NVCStage::showAndWait); }); } @@ -600,9 +601,9 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro projectSettingsViewController = new ProjectSettingsViewController(mainViewController.getScreen(), mainStage, openProject, onFinish); - projectSettingsViewController.getStage().show(); - } else if (projectSettingsViewController.getStage().isShowing()) { - projectSettingsViewController.getStage().toFront(); + projectSettingsViewController.getStageContainer().ifPresent(NVCStage::show); + } else if (projectSettingsViewController.getStageContainer().isPresent() && projectSettingsViewController.getStageContainer().get().getStage().isShowing()) { + projectSettingsViewController.getStageContainer().get().getStage().toFront(); } } @@ -629,9 +630,9 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro profileSettingsViewController = new ProfileSettingsViewController(midi, mainViewController.getScreen(), mainStage, openProject, onFinish); - profileSettingsViewController.getStage().show(); - } else if (profileSettingsViewController.getStage().isShowing()) { - profileSettingsViewController.getStage().toFront(); + profileSettingsViewController.getStageContainer().ifPresent(NVCStage::show); + } else if (profileSettingsViewController.getStageContainer().isPresent() && profileSettingsViewController.getStageContainer().get().getStage().isShowing()) { + profileSettingsViewController.getStageContainer().get().getStage().toFront(); } } @@ -647,9 +648,9 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro }; globalSettingsViewController = new GlobalSettingsViewController(mainStage, onFinish); - globalSettingsViewController.getStage().show(); + globalSettingsViewController.getStageContainer().ifPresent(NVCStage::show); } else { - globalSettingsViewController.getStage().toFront(); + globalSettingsViewController.getStageContainer().get().getStage().toFront(); } } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java index cfbd6be3..2bc58a61 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java @@ -1,10 +1,5 @@ package de.tobias.playpad.layout.desktop.pad; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Set; - import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.layout.desktop.DesktopEditMode; @@ -12,16 +7,11 @@ import de.tobias.playpad.layout.desktop.DesktopMainLayoutFactory; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.TimeMode; -import de.tobias.playpad.pad.content.PadContent; import de.tobias.playpad.pad.content.ContentFactory; +import de.tobias.playpad.pad.content.PadContent; import de.tobias.playpad.pad.content.PadContentRegistry; import de.tobias.playpad.pad.content.play.Durationable; -import de.tobias.playpad.pad.listener.IPadPositionListener; -import de.tobias.playpad.pad.listener.PadContentListener; -import de.tobias.playpad.pad.listener.PadDurationListener; -import de.tobias.playpad.pad.listener.PadLockedListener; -import de.tobias.playpad.pad.listener.PadPositionListener; -import de.tobias.playpad.pad.listener.PadStatusListener; +import de.tobias.playpad.pad.listener.*; import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.registry.NoSuchComponentException; @@ -32,6 +22,7 @@ import de.tobias.playpad.view.FileDragOptionView; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.pad.PadSettingsViewController; import de.tobias.utils.application.ApplicationUtils; +import de.tobias.utils.nui.NVCStage; import de.tobias.utils.util.FileUtils; import de.tobias.utils.util.Localization; import javafx.beans.value.ChangeListener; @@ -43,6 +34,11 @@ import javafx.stage.FileChooser.ExtensionFilter; import javafx.stage.Stage; import javafx.util.Duration; +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Set; + public class DesktopPadViewController implements IPadViewController, EventHandler<ActionEvent> { private static final String OPEN_FOLDER = "openFolder"; @@ -280,15 +276,18 @@ public class DesktopPadViewController implements IPadViewController, EventHandle Stage owner = mvc.getStage(); PadSettingsViewController padSettingsViewController = new PadSettingsViewController(pad, owner); - padSettingsViewController.getStage().setOnHiding(ev -> - { - if (padView != null && pad != null) - padView.setTriggerLabelActive(pad.getPadSettings().hasTriggerItems()); + padSettingsViewController.getStageContainer().ifPresent(nvcStage -> { + nvcStage.addCloseHook(() -> { + if (padView != null && pad != null) + padView.setTriggerLabelActive(pad.getPadSettings().hasTriggerItems()); + return true; + }); }); - padSettingsViewController.getStage().show(); + padSettingsViewController.getStageContainer().ifPresent(NVCStage::show); } } + @Override public void updateTimeLabel() { if (pad.getContent() != null && pad.getStatus() != PadStatus.EMPTY && pad.getStatus() != PadStatus.ERROR) { @@ -391,7 +390,7 @@ public class DesktopPadViewController implements IPadViewController, EventHandle padView.getNewButton().setDisable(true); padView.getSettingsButton().setDisable(true); } - + // Alles Desktivieren, wenn nicht Play Mode if (connect.getEditMode() != DesktopEditMode.PLAY) { padView.getPlayButton().setDisable(true); diff --git a/PlayWall/src/de/tobias/playpad/trigger/CartTriggerItemFactory.java b/PlayWall/src/de/tobias/playpad/trigger/CartTriggerItemFactory.java index 89ae2f4f..3c16e36e 100644 --- a/PlayWall/src/de/tobias/playpad/trigger/CartTriggerItemFactory.java +++ b/PlayWall/src/de/tobias/playpad/trigger/CartTriggerItemFactory.java @@ -5,6 +5,7 @@ import de.tobias.playpad.tigger.Trigger; import de.tobias.playpad.tigger.TriggerItem; import de.tobias.playpad.tigger.TriggerItemFactory; import de.tobias.playpad.viewcontroller.option.pad.trigger.CartTriggerViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontIconType; import de.tobias.utils.util.Localization; @@ -21,7 +22,7 @@ public class CartTriggerItemFactory extends TriggerItemFactory { } @Override - public ContentViewController getSettingsController(TriggerItem item) { + public NVC getSettingsController(TriggerItem item) { return new CartTriggerViewController((CartTriggerItem) item); } diff --git a/PlayWall/src/de/tobias/playpad/trigger/VolumeTriggerItemFactory.java b/PlayWall/src/de/tobias/playpad/trigger/VolumeTriggerItemFactory.java index c3a12202..895ab493 100644 --- a/PlayWall/src/de/tobias/playpad/trigger/VolumeTriggerItemFactory.java +++ b/PlayWall/src/de/tobias/playpad/trigger/VolumeTriggerItemFactory.java @@ -5,6 +5,7 @@ import de.tobias.playpad.tigger.Trigger; import de.tobias.playpad.tigger.TriggerItem; import de.tobias.playpad.tigger.TriggerItemFactory; import de.tobias.playpad.viewcontroller.option.pad.trigger.VolumeTriggerViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontIconType; import de.tobias.utils.util.Localization; @@ -21,7 +22,7 @@ public class VolumeTriggerItemFactory extends TriggerItemFactory { } @Override - public ContentViewController getSettingsController(TriggerItem item) { + public NVC getSettingsController(TriggerItem item) { return new VolumeTriggerViewController((VolumeTriggerItem) item); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java index e3dc06be..0ce49bed 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/LaunchDialog.java @@ -6,6 +6,8 @@ import java.io.File; import java.io.IOException; import java.nio.file.Path; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; @@ -43,7 +45,7 @@ import javafx.stage.FileChooser.ExtensionFilter; import javafx.stage.Modality; import javafx.stage.Stage; -public class LaunchDialog extends ViewController implements ProfileChooseable { +public class LaunchDialog extends NVC implements ProfileChooseable { private static final String IMAGE = "icon.png"; @@ -58,8 +60,10 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { @FXML private Button deleteButton; public LaunchDialog(Stage stage) { - super("launchDialog", "de/tobias/playpad/assets/dialog/", stage, null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/dialog/", "launchDialog", PlayPadMain.getUiResourceBundle()); projectListView.getItems().addAll(ProjectReferences.getProjectsSorted()); + + applyViewControllerToStage(stage); } @Override @@ -104,8 +108,8 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { @Override public void initStage(Stage stage) { - setCSS("style.css", "de/tobias/playpad/assets/"); - setCSS("launchDialog_style.css", "de/tobias/playpad/assets/style/"); + stage.getScene().getStylesheets().add("de/tobias/playpad/assets/style.css"); + stage.getScene().getStylesheets().add("de/tobias/playpad/assets/style/launchDialog_style.css"); stage.setTitle(getString(Strings.UI_Dialog_Launch_Title)); PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); @@ -118,13 +122,13 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { @FXML private void newProfileButtonHandler(ActionEvent event) { - NewProjectDialog dialog = new NewProjectDialog(getStage()); - dialog.getStage().showAndWait(); + NewProjectDialog dialog = new NewProjectDialog(getContainingWindow()); + dialog.getStageContainer().ifPresent(NVCStage::showAndWait); Project project = dialog.getProject(); if (project != null) { PlayPadMain.getProgramInstance().openProject(project); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } } @@ -132,11 +136,11 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { private void importProfileButtonHandler(ActionEvent event) { FileChooser chooser = new FileChooser(); chooser.getExtensionFilters().add(new ExtensionFilter(getString(Strings.File_Filter_ZIP), PlayPadMain.projectZIPType)); - File file = chooser.showOpenDialog(getStage()); + File file = chooser.showOpenDialog(getContainingWindow()); if (file != null) { Path zipFile = file.toPath(); try { - ImportDialog importDialog = ImportDialog.getInstance(getStage()); + ImportDialog importDialog = ImportDialog.getInstance(getContainingWindow()); ProjectReference ref = ProjectImporter.importProject(zipFile, importDialog, importDialog); if (ref != null) { launchProject(ref); @@ -163,7 +167,7 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { Stage dialog = (Stage) alert.getDialogPane().getScene().getWindow(); PlayPadMain.stageIcon.ifPresent(dialog.getIcons()::add); - alert.initOwner(getStage()); + alert.initOwner(getContainingWindow()); alert.initModality(Modality.WINDOW_MODAL); alert.showAndWait().filter(item -> item == ButtonType.OK).ifPresent(item -> @@ -197,14 +201,14 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { // Es fehlen Module if (!ref.getMissedModules().isEmpty()) { showInfoMessage(Localization.getString(Strings.Error_Plugins_Missing)); - PluginViewController controller = new PluginViewController(getStage(), ref.getMissedModules()); - controller.getStage().showAndWait(); + PluginViewController controller = new PluginViewController(getContainingWindow(), ref.getMissedModules()); + controller.getStageContainer().ifPresent(NVCStage::showAndWait); } try { Project project = Project.load(ref, true, this); PlayPadMain.getProgramInstance().openProject(project); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } catch (ProfileNotFoundException e) { e.printStackTrace(); showErrorMessage(getString(Strings.Error_Profile_NotFound, ref.getProfileReference(), e.getLocalizedMessage())); @@ -224,9 +228,9 @@ public class LaunchDialog extends ViewController implements ProfileChooseable { // Zeigt dialog für das Ausfählen eines neuen Profiles. @Override public Profile getUnkownProfile() { - ProfileChooseDialog dialog = new ProfileChooseDialog(getStage()); + ProfileChooseDialog dialog = new ProfileChooseDialog(getContainingWindow()); - dialog.getStage().showAndWait(); + dialog.getStageContainer().ifPresent(NVCStage::showAndWait); Profile profile = dialog.getProfile(); if (profile != null) { return profile; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionTypeViewController.java similarity index 88% rename from PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java rename to PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionTypeViewController.java index 9f8b7fa9..b8f9ba79 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionTypeViewController.java @@ -5,6 +5,7 @@ import java.util.List; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.action.ActionFactory; import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.utils.nui.NVC; import org.controlsfx.control.SegmentedButton; import de.tobias.playpad.PlayPadMain; @@ -32,23 +33,17 @@ import javafx.scene.layout.VBox; * * @author tobias */ -public class CartActionsViewController extends ContentViewController { +public class CartActionTypeViewController extends NVC { - @FXML - private VBox buttonVbox; - - private ToggleGroup cartsToggle; - @FXML - private GridPane gridPane; - - @FXML - private VBox cartActionContainer; + @FXML private VBox buttonVbox; + @FXML private GridPane gridPane; + @FXML private VBox cartActionContainer; private Mapping mapping; private IMappingTabViewController parentController; - public CartActionsViewController(Mapping mapping, IMappingTabViewController parentController) { - super("cartActions", "de/tobias/playpad/assets/view/actions/", PlayPadMain.getUiResourceBundle()); + public CartActionTypeViewController(Mapping mapping, IMappingTabViewController parentController) { + load("de/tobias/playpad/assets/view/actions/", "cartActions", PlayPadMain.getUiResourceBundle()); this.mapping = mapping; this.parentController = parentController; @@ -83,7 +78,7 @@ public class CartActionsViewController extends ContentViewController { gridPane.getRowConstraints().add(c); } - cartsToggle = new ToggleGroup(); + ToggleGroup cartsToggle = new ToggleGroup(); int index = 0; @@ -108,7 +103,7 @@ public class CartActionsViewController extends ContentViewController { List<CartAction> cartActions = mapping.getActions(actionFactory); for (CartAction action : cartActions) { if (action.getX() == currentX && action.getY() == currentY) { - ContentViewController actionViewController = action.getSettingsViewController(); + NVC actionViewController = action.getSettingsViewController(); cartActionContainer.getChildren().setAll(actionViewController.getParent()); cartActionContainer.setVisible(true); parentController.showMapperFor(action); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionViewController.java index c53586b9..2117cccd 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/actions/CartActionViewController.java @@ -7,6 +7,7 @@ import de.tobias.playpad.action.cartaction.CartAction.ControlMode; import de.tobias.playpad.action.mapper.MapperViewController; import de.tobias.playpad.viewcontroller.BaseMapperOverviewViewController; import de.tobias.playpad.viewcontroller.cell.EnumCell; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import javafx.fxml.FXML; import javafx.scene.control.CheckBox; @@ -14,7 +15,7 @@ import javafx.scene.control.ComboBox; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -public class CartActionViewController extends ContentViewController { +public class CartActionViewController extends NVC { @FXML private ComboBox<ControlMode> controlMode; @FXML private CheckBox autoColorCheckbox; @@ -25,7 +26,7 @@ public class CartActionViewController extends ContentViewController { private CartAction action; public CartActionViewController() { - super("cartAction", "de/tobias/playpad/assets/view/actions/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/actions/", "cartAction", PlayPadMain.getUiResourceBundle()); } @Override diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicCartDesignViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicCartDesignViewController.java index 169b7bcc..e8379b89 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicCartDesignViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicCartDesignViewController.java @@ -25,7 +25,8 @@ public class ClassicCartDesignViewController extends CartDesignViewController { @FXML private Button resetButton; public ClassicCartDesignViewController(CartDesign layout) { - super("classicLayoutCart", "de/tobias/playpad/assets/view/option/layout/", PlayPadMain.getUiResourceBundle(), layout); + super(layout); + load("de/tobias/playpad/assets/view/option/layout/", "classicLayoutCart", PlayPadMain.getUiResourceBundle()); setLayout((ClassicCartDesign) layout); } @@ -88,7 +89,6 @@ public class ClassicCartDesignViewController extends CartDesignViewController { setLayout(layout); } - @Override public void updateData() { backgroundColorPicker.setValue(layout.getBackgroundColor()); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicGlobalDesignViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicGlobalDesignViewController.java index ec4009fc..8c60f54a 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicGlobalDesignViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ClassicGlobalDesignViewController.java @@ -44,7 +44,8 @@ public class ClassicGlobalDesignViewController extends GlobalDesignViewControlle @FXML private Button resetButton; public ClassicGlobalDesignViewController(GlobalDesign layout) { - super("classicLayoutGlobal", "de/tobias/playpad/assets/view/option/layout/", PlayPadMain.getUiResourceBundle(), layout); + super(layout); + load("de/tobias/playpad/assets/view/option/layout/", "classicLayoutGlobal", PlayPadMain.getUiResourceBundle()); setLayout((ClassicGlobalDesign) layout); ClassicGlobalDesign cl = (ClassicGlobalDesign) layout; @@ -162,7 +163,6 @@ public class ClassicGlobalDesignViewController extends GlobalDesignViewControlle setLayout(layout); } - @Override public void updateData() { backgroundColorPicker.setValue(layout.getBackgroundColor()); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java index 99644a91..77351c14 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java @@ -30,13 +30,11 @@ public class ModernCartDesignViewController extends CartDesignViewController { private PopOver colorChooser; public ModernCartDesignViewController(CartDesign layout) { - super("modernLayoutCart", "de/tobias/playpad/assets/view/option/layout/", PlayPadMain.getUiResourceBundle(), layout); + super(layout); + load("de/tobias/playpad/assets/view/option/layout/", "modernLayoutCart", PlayPadMain.getUiResourceBundle()); - if (layout instanceof CartDesign) { - this.cartLayout = (ModernCartDesign) layout; - - setLayout(); - } + this.cartLayout = (ModernCartDesign) layout; + setLayout(); } private void setLayout() { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java index d90331f5..525db013 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java @@ -36,13 +36,11 @@ public class ModernGlobalDesignViewController extends GlobalDesignViewController private PopOver colorChooser; public ModernGlobalDesignViewController(GlobalDesign layout) { - super("modernLayoutGlobal", "de/tobias/playpad/assets/view/option/layout/", PlayPadMain.getUiResourceBundle(), layout); + super(layout); + load("de/tobias/playpad/assets/view/option/layout/", "modernLayoutGlobal", PlayPadMain.getUiResourceBundle()); - if (layout instanceof GlobalDesign) { - this.globalLayout = (ModernGlobalDesign) layout; - - setLayout(); - } + this.globalLayout = (ModernGlobalDesign) layout; + setLayout(); } private void setLayout() { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProfileDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProfileDialog.java index da7c8336..8caef907 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProfileDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProfileDialog.java @@ -7,6 +7,7 @@ import de.tobias.playpad.Strings; import de.tobias.playpad.profile.ref.ProfileReference; import de.tobias.playpad.profile.ref.ProfileReferences; import de.tobias.playpad.settings.Profile; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; import javafx.scene.control.Button; @@ -19,8 +20,8 @@ public class DuplicateProfileDialog extends TextInputDialog { private ProfileReference newRef; - public DuplicateProfileDialog(ViewController controller, ProfileReference cloneableProfile) { - initOwner(controller.getStage()); + public DuplicateProfileDialog(NVC controller, ProfileReference cloneableProfile) { + initOwner(controller.getContainingWindow()); initModality(Modality.WINDOW_MODAL); Stage dialog = (Stage) getDialogPane().getScene().getWindow(); PlayPadMain.stageIcon.ifPresent(dialog.getIcons()::add); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java index 8b14194e..efc0f104 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/DuplicateProjectDialog.java @@ -8,6 +8,7 @@ import de.tobias.playpad.profile.ref.ProfileReferences; import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.project.ref.ProjectReferences; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; import javafx.scene.control.Button; @@ -16,13 +17,14 @@ import javafx.scene.control.ButtonType; import javafx.scene.control.TextInputDialog; import javafx.stage.Modality; import javafx.stage.Stage; +import javafx.stage.Window; public class DuplicateProjectDialog extends TextInputDialog { private ProjectReference ref; - public DuplicateProjectDialog(ViewController controller, ProjectReference cloneableProject) { - initOwner(controller.getStage()); + public DuplicateProjectDialog(NVC controller, ProjectReference cloneableProject) { + initOwner(controller.getContainingWindow()); initModality(Modality.WINDOW_MODAL); Stage dialog = (Stage) getDialogPane().getScene().getWindow(); PlayPadMain.stageIcon.ifPresent(dialog.getIcons()::add); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ImportDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ImportDialog.java index e5e1ba47..11ed7933 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ImportDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ImportDialog.java @@ -9,6 +9,7 @@ import de.tobias.playpad.Strings; import de.tobias.playpad.project.Importable; import de.tobias.playpad.project.ProfileChooseable; import de.tobias.playpad.settings.Profile; +import de.tobias.utils.nui.NVCStage; import de.tobias.utils.util.Localization; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; @@ -17,22 +18,23 @@ import javafx.scene.control.TextInputDialog; import javafx.stage.DirectoryChooser; import javafx.stage.Modality; import javafx.stage.Stage; +import javafx.stage.Window; public class ImportDialog implements Importable, ProfileChooseable { private static ImportDialog instance; - private static Stage owner; + private static Window owner; static { instance = new ImportDialog(); } - public static ImportDialog getInstance(Stage stage) { + public static ImportDialog getInstance(Window stage) { ImportDialog.owner = stage; return instance; } - private Stage getStage() { + private Window getStage() { return owner; } @@ -120,7 +122,7 @@ public class ImportDialog implements Importable, ProfileChooseable { public Profile getUnkownProfile() { ProfileChooseDialog dialog = new ProfileChooseDialog(getStage()); - dialog.getStage().showAndWait(); + dialog.getStageContainer().ifPresent(NVCStage::showAndWait); Profile profile = dialog.getProfile(); if (profile != null) { return profile; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProfileDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProfileDialog.java index 292a1694..54c36f49 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProfileDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProfileDialog.java @@ -10,6 +10,8 @@ import de.tobias.playpad.midi.Midi; import de.tobias.playpad.profile.ref.ProfileReference; import de.tobias.playpad.profile.ref.ProfileReferences; import de.tobias.playpad.settings.Profile; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; import de.tobias.utils.util.Worker; @@ -26,7 +28,7 @@ import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window; -public class NewProfileDialog extends ViewController { +public class NewProfileDialog extends NVC { @FXML private TextField nameTextField; @FXML private CheckBox activeCheckBox; @@ -40,11 +42,13 @@ public class NewProfileDialog extends ViewController { private Profile profile; - public NewProfileDialog(Window owner) { - super("newProfileDialog", "de/tobias/playpad/assets/dialog/", null, PlayPadMain.getUiResourceBundle()); + NewProfileDialog(Window owner) { + load("de/tobias/playpad/assets/dialog/", "newProfileDialog", PlayPadMain.getUiResourceBundle()); - getStage().initOwner(owner); - getStage().initModality(Modality.WINDOW_MODAL); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + nvcStage.getStage().sizeToScene(); + addCloseKeyShortcut(() -> getStageContainer().ifPresent(NVCStage::close)); midiDeviceComboBox.setDisable(!activeCheckBox.isSelected()); @@ -63,7 +67,6 @@ public class NewProfileDialog extends ViewController { } }); }); - getStage().sizeToScene(); } private boolean expand = false; @@ -74,12 +77,19 @@ public class NewProfileDialog extends ViewController { { if (newHeight.doubleValue() > oldHeight.doubleValue()) { if (accordionParent.getHeight() <= newHeight.doubleValue()) { - getStage().setHeight(getStage().getHeight() + newHeight.doubleValue()); + getStageContainer().ifPresent(nvcStage -> { + Stage stage = nvcStage.getStage(); + stage.setHeight(stage.getHeight() + newHeight.doubleValue()); + }); expand = true; } } else { - if (expand) - getStage().setHeight(getStage().getHeight() - oldHeight.doubleValue()); + if (expand) { + getStageContainer().ifPresent(nvcStage -> { + Stage stage = nvcStage.getStage(); + stage.setHeight(stage.getHeight() - oldHeight.doubleValue()); + }); + } expand = false; } }); @@ -97,8 +107,6 @@ public class NewProfileDialog extends ViewController { } }); finishButton.setDisable(true); - - addCloseKeyShortcut(() -> getStage().close()); } @Override @@ -114,8 +122,10 @@ public class NewProfileDialog extends ViewController { stage.setMaxWidth(500); + stage.initModality(Modality.WINDOW_MODAL); + if (Profile.currentProfile() != null) { - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } } @@ -141,7 +151,7 @@ public class NewProfileDialog extends ViewController { profile.getProfileSettings().setMidiDeviceName(midiDeviceComboBox.getSelectionModel().getSelectedItem()); profile.save(); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } catch (Exception e) { e.printStackTrace(); showErrorMessage(Localization.getString(Strings.Error_Profile_Create, e.getMessage())); @@ -150,7 +160,7 @@ public class NewProfileDialog extends ViewController { @FXML private void cancelButtonHandler(ActionEvent event) { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } public Profile getProfile() { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java index 9f12a82e..174d7d0c 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/NewProjectDialog.java @@ -5,6 +5,8 @@ import java.io.IOException; import java.nio.file.Path; import java.util.UUID; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; @@ -36,7 +38,7 @@ import javafx.stage.Window; * @author tobias * */ -public class NewProjectDialog extends ViewController { +public class NewProjectDialog extends NVC { @FXML private TextField nameTextField; @FXML private ComboBox<ProfileReference> profileComboBox; @@ -54,10 +56,11 @@ public class NewProjectDialog extends ViewController { private Path newMediaPath; // Ausgewählter Ordner (temp) public NewProjectDialog(Window owner) { - super("newProjectDialog", "de/tobias/playpad/assets/dialog/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/dialog/", "newProjectDialog", PlayPadMain.getUiResourceBundle()); - getStage().initOwner(owner); - getStage().initModality(Modality.WINDOW_MODAL); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + addCloseKeyShortcut(() -> getStageContainer().ifPresent(NVCStage::close)); profileComboBox.getItems().addAll(ProfileReferences.getProfiles()); profileComboBox.getSelectionModel().selectFirst(); @@ -88,8 +91,6 @@ public class NewProjectDialog extends ViewController { } }); mediaButtonChoose.setDisable(true); - - addCloseKeyShortcut(() -> getStage().close()); } @Override @@ -105,8 +106,10 @@ public class NewProjectDialog extends ViewController { stage.setMaxWidth(560); + stage.initModality(Modality.WINDOW_MODAL); + if (Profile.currentProfile() != null) { - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } } @@ -114,7 +117,7 @@ public class NewProjectDialog extends ViewController { private void mediaButtonHandler(ActionEvent event) { if (mediaPathCheckbox.isSelected()) { DirectoryChooser chooser = new DirectoryChooser(); - File file = chooser.showDialog(getStage()); + File file = chooser.showDialog(getContainingWindow()); if (file != null) { newMediaPath = file.toPath(); mediaPathLabel.setText(newMediaPath.toString()); @@ -142,7 +145,7 @@ public class NewProjectDialog extends ViewController { ProjectReferences.addProject(projectReference); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } catch (IOException | DocumentException | ProfileNotFoundException e) { showErrorMessage(Localization.getString(Strings.Error_Project_Create, e.getLocalizedMessage())); e.printStackTrace(); @@ -151,13 +154,13 @@ public class NewProjectDialog extends ViewController { @FXML private void cancelButtonHandler(ActionEvent event) { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } @FXML private void newProfileButtonHandler(ActionEvent event) { - NewProfileDialog dialog = new NewProfileDialog(getStage()); - dialog.getStage().showAndWait(); + NewProfileDialog dialog = new NewProfileDialog(getContainingWindow()); + dialog.getStageContainer().ifPresent(NVCStage::showAndWait); Profile profile = dialog.getProfile(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java index cf25ad25..cccd0cf5 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PluginViewController.java @@ -5,6 +5,8 @@ import java.util.Collections; import java.util.List; import java.util.Set; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.bukkit.configuration.MemorySection; import de.tobias.playpad.AppUserInfoStrings; @@ -32,7 +34,7 @@ import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window; -public class PluginViewController extends ViewController { +public class PluginViewController extends NVC { @FXML private ListView<PluginDescription> pluginListView; @FXML private Button finishButton; @@ -42,10 +44,11 @@ public class PluginViewController extends ViewController { } public PluginViewController(Window owner, Set<Module> modules) { - super("pluginView", "de/tobias/playpad/assets/dialog/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/dialog/", "pluginView", PlayPadMain.getUiResourceBundle()); - getStage().initOwner(owner); - getStage().initModality(Modality.WINDOW_MODAL); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + addCloseKeyShortcut(() -> getStageContainer().ifPresent(NVCStage::close)); Worker.runLater(() -> { @@ -97,8 +100,6 @@ public class PluginViewController extends ViewController { public void init() { pluginListView.setCellFactory(list -> new PluginCell()); pluginListView.setPlaceholder(new Label(Localization.getString(Strings.UI_Placeholder_Plugins))); - - addCloseKeyShortcut(() -> getStage().close()); } @Override @@ -110,13 +111,14 @@ public class PluginViewController extends ViewController { stage.setMinHeight(500); stage.setTitle(Localization.getString(Strings.UI_Dialog_Plugins_Title)); + stage.initModality(Modality.WINDOW_MODAL); if (Profile.currentProfile() != null) - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } @FXML private void finishButtonHandler(ActionEvent event) { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } } \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java index d4fe619c..473fdbe9 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java @@ -18,6 +18,8 @@ import de.tobias.playpad.project.page.Page; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.cell.PageNameListCell; import de.tobias.utils.application.ApplicationUtils; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; @@ -35,7 +37,7 @@ import javafx.scene.web.WebView; import javafx.stage.Stage; import javafx.stage.Window; -public class PrintDialog extends ViewController { +public class PrintDialog extends NVC { @FXML private WebView webView; @FXML private ComboBox<Integer> pageComboBox; @@ -45,7 +47,7 @@ public class PrintDialog extends ViewController { private Project project; public PrintDialog(Project project, Window owner) { - super("printDialog", "de/tobias/playpad/assets/dialog/project/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/dialog/project/", "printDialog", PlayPadMain.getUiResourceBundle()); this.project = project; int pages = project.getPages().size(); @@ -56,7 +58,9 @@ public class PrintDialog extends ViewController { pageComboBox.setCellFactory(param -> new PageNameListCell()); pageComboBox.setButtonCell(new PageNameListCell()); - getStage().initOwner(owner); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + addCloseKeyShortcut(() -> getStageContainer().ifPresent(NVCStage::close)); } @Override @@ -65,8 +69,6 @@ public class PrintDialog extends ViewController { { createPreview(c); }); - - addCloseKeyShortcut(() -> getStage().close()); } @Override @@ -77,7 +79,7 @@ public class PrintDialog extends ViewController { stage.setMinHeight(400); stage.setTitle(Localization.getString(Strings.UI_Dialog_Print_Title)); - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } private void createPreview(int pageIndex) { @@ -132,7 +134,7 @@ public class PrintDialog extends ViewController { @FXML private void cancelButtonHandler(ActionEvent event) { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } @FXML @@ -142,10 +144,10 @@ public class PrintDialog extends ViewController { PrinterJob job = PrinterJob.createPrinterJob(printer); job.getJobSettings().setPageLayout(layout); job.getJobSettings().setJobName(ApplicationUtils.getApplication().getInfo().getName()); - if (job != null && job.showPrintDialog(getStage())) { + if (job.showPrintDialog(getContainingWindow())) { webView.getEngine().print(job); job.endJob(); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileChooseDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileChooseDialog.java index d516fcd3..e1fcd664 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileChooseDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileChooseDialog.java @@ -2,6 +2,8 @@ package de.tobias.playpad.viewcontroller.dialog; import java.io.IOException; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; @@ -20,7 +22,7 @@ import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window; -public class ProfileChooseDialog extends ViewController { +public class ProfileChooseDialog extends NVC { @FXML private ComboBox<ProfileReference> profileComboBox; @FXML private Button newProfileButton; @@ -31,10 +33,10 @@ public class ProfileChooseDialog extends ViewController { private Profile profile; public ProfileChooseDialog(Window owner) { - super("profileChooseDialog", "de/tobias/playpad/assets/dialog/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/dialog/", "profileChooseDialog", PlayPadMain.getUiResourceBundle()); - getStage().initOwner(owner); - getStage().initModality(Modality.WINDOW_MODAL); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); profileComboBox.getItems().addAll(ProfileReferences.getProfiles()); profileComboBox.getSelectionModel().selectFirst(); @@ -51,8 +53,10 @@ public class ProfileChooseDialog extends ViewController { stage.setMinHeight(180); stage.setMaxWidth(560); + stage.initModality(Modality.WINDOW_MODAL); + if (Profile.currentProfile() != null) { - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } } @@ -61,7 +65,7 @@ public class ProfileChooseDialog extends ViewController { try { profile = Profile.load(profileComboBox.getSelectionModel().getSelectedItem()); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } catch (IOException | DocumentException | ProfileNotFoundException e) { showErrorMessage(Localization.getString(Strings.Error_Profile_Save, e.getLocalizedMessage())); e.printStackTrace(); @@ -70,13 +74,13 @@ public class ProfileChooseDialog extends ViewController { @FXML private void cancelButtonHandler(ActionEvent event) { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } @FXML private void newProfileButtonHandler(ActionEvent event) { - NewProfileDialog dialog = new NewProfileDialog(getStage()); - dialog.getStage().showAndWait(); + NewProfileDialog dialog = new NewProfileDialog(getContainingWindow()); + dialog.getStageContainer().ifPresent(NVCStage::showAndWait); Profile profile = dialog.getProfile(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileViewController.java index 293390b3..6f4bc459 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProfileViewController.java @@ -2,6 +2,8 @@ package de.tobias.playpad.viewcontroller.dialog; import java.io.IOException; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; @@ -29,7 +31,7 @@ import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window; -public class ProfileViewController extends ViewController implements ChangeListener<ProfileReference> { +public class ProfileViewController extends NVC implements ChangeListener<ProfileReference> { @FXML private ListView<ProfileReference> profileList; @FXML private TextField nameTextField; @@ -44,12 +46,13 @@ public class ProfileViewController extends ViewController implements ChangeListe private Project project; public ProfileViewController(Window owner, Project project) { - super("profileSettingsView", "de/tobias/playpad/assets/dialog/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/dialog/", "profileSettingsView", PlayPadMain.getUiResourceBundle()); profileList.getSelectionModel().select(Profile.currentProfile().getRef()); this.project = project; - getStage().initOwner(owner); - getStage().initModality(Modality.WINDOW_MODAL); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + addCloseKeyShortcut(() -> getStageContainer().ifPresent(NVCStage::close)); if (ProfileReferences.getProfiles().size() == 1 || profileList.getSelectionModel().getSelectedItem().equals(Profile.currentProfile().getRef())) { @@ -81,8 +84,6 @@ public class ProfileViewController extends ViewController implements ChangeListe }); profileList.getSelectionModel().selectedItemProperty().addListener(this); - - addCloseKeyShortcut(() -> getStage().close()); } @Override @@ -93,7 +94,8 @@ public class ProfileViewController extends ViewController implements ChangeListe stage.setMinWidth(375); stage.setMinHeight(500); - Profile.currentProfile().currentLayout().applyCss(getStage()); + stage.initModality(Modality.WINDOW_MODAL); + Profile.currentProfile().currentLayout().applyCss(stage); } @FXML @@ -106,13 +108,13 @@ public class ProfileViewController extends ViewController implements ChangeListe } catch (ProfileNotFoundException | DocumentException | IOException e) { e.printStackTrace(); } - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } @FXML private void newButtonHandler(ActionEvent event) { - NewProfileDialog dialog = new NewProfileDialog(getStage()); - dialog.getStage().showAndWait(); + NewProfileDialog dialog = new NewProfileDialog(getContainingWindow()); + dialog.getStageContainer().ifPresent(NVCStage::showAndWait); Profile profile = dialog.getProfile(); @@ -140,7 +142,7 @@ public class ProfileViewController extends ViewController implements ChangeListe private void deleteButtonHandler() { Alert alert = new Alert(AlertType.CONFIRMATION); - alert.initOwner(getStage()); + alert.initOwner(getContainingWindow()); alert.initModality(Modality.WINDOW_MODAL); Stage dialog = (Stage) alert.getDialogPane().getScene().getWindow(); PlayPadMain.stageIcon.ifPresent(dialog.getIcons()::add); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectExportDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectExportDialog.java index e730c2d2..c6a9f07f 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectExportDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectExportDialog.java @@ -10,9 +10,10 @@ import de.tobias.playpad.project.ProjectExporter; import de.tobias.playpad.project.ProjectExporter.ExportView; import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.Profile; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import de.tobias.utils.ui.NotificationHandler; -import de.tobias.utils.ui.ViewController; -import de.tobias.utils.ui.scene.BusyView; +import de.tobias.utils.nui.BusyView; import de.tobias.utils.util.Localization; import de.tobias.utils.util.Worker; import javafx.application.Platform; @@ -27,7 +28,7 @@ import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window; -public class ProjectExportDialog extends ViewController implements ExportView { +public class ProjectExportDialog extends NVC implements ExportView { @FXML private CheckBox profileCheckBox; @FXML private CheckBox mediaCheckBox; @@ -40,13 +41,13 @@ public class ProjectExportDialog extends ViewController implements ExportView { private ProjectReference projectRef; private NotificationHandler notificationHandler; - public ProjectExportDialog(ProjectReference projectRef, Window owner, NotificationHandler notificationHandler) { - super("exportDialog", "de/tobias/playpad/assets/dialog/project/", null, PlayPadMain.getUiResourceBundle()); + ProjectExportDialog(ProjectReference projectRef, Window owner, NotificationHandler notificationHandler) { + load("de/tobias/playpad/assets/dialog/project/", "exportDialog", PlayPadMain.getUiResourceBundle()); this.projectRef = projectRef; this.notificationHandler = notificationHandler; - getStage().initOwner(owner); - getStage().initModality(Modality.WINDOW_MODAL); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); busyView = new BusyView(this); } @@ -58,13 +59,14 @@ public class ProjectExportDialog extends ViewController implements ExportView { stage.setTitle(Localization.getString(Strings.UI_Dialog_ProjectExport_Title)); stage.setWidth(375); stage.setHeight(180); + stage.initModality(Modality.WINDOW_MODAL); - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } @FXML private void cancelButtonHandler(ActionEvent event) { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } @FXML @@ -76,7 +78,7 @@ public class ProjectExportDialog extends ViewController implements ExportView { ExtensionFilter extensionFilter = new ExtensionFilter(extensionName, PlayPadMain.projectZIPType); chooser.getExtensionFilters().add(extensionFilter); - File file = chooser.showSaveDialog(getStage()); + File file = chooser.showSaveDialog(getContainingWindow()); if (file != null) { cancelButton.setDisable(true); @@ -94,7 +96,7 @@ public class ProjectExportDialog extends ViewController implements ExportView { Platform.runLater(() -> { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); String notificationString = Localization.getString(Strings.Standard_File_Save); notificationHandler.notify(notificationString, PlayPadMain.displayTimeMillis); @@ -122,7 +124,7 @@ public class ProjectExportDialog extends ViewController implements ExportView { @Override public void tastComplete() { if (!Platform.isFxApplicationThread()) { - Platform.runLater(() -> tastComplete()); + Platform.runLater(this::tastComplete); return; } complete++; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java index 13f99b03..7d45a9b2 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java @@ -5,6 +5,8 @@ import java.io.IOException; import java.nio.file.Path; import java.util.Optional; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; @@ -39,7 +41,7 @@ import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.Window; -public class ProjectManagerDialog extends ViewController implements NotificationHandler { +public class ProjectManagerDialog extends NVC implements NotificationHandler { @FXML private ListView<ProjectReference> projectList; @@ -67,13 +69,14 @@ public class ProjectManagerDialog extends ViewController implements Notification private boolean cancel = false; public ProjectManagerDialog(Window owner, Project currentProject) { - super("openDialog", "de/tobias/playpad/assets/dialog/project/", null, PlayPadMain.getUiResourceBundle()); - this.currentProject = currentProject; + load("de/tobias/playpad/assets/dialog/project/", "openDialog", PlayPadMain.getUiResourceBundle()); - projectList.getItems().setAll(ProjectReferences.getProjectsSorted()); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + addCloseKeyShortcut(() -> getStageContainer().ifPresent(NVCStage::close)); - getStage().initOwner(owner); - getStage().initModality(Modality.WINDOW_MODAL); + this.currentProject = currentProject; + this.projectList.getItems().setAll(ProjectReferences.getProjectsSorted()); } @Override @@ -93,7 +96,7 @@ public class ProjectManagerDialog extends ViewController implements Notification if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { if (!projectList.getSelectionModel().isEmpty()) { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } } } @@ -145,8 +148,6 @@ public class ProjectManagerDialog extends ViewController implements Notification profileLabel.setText("-"); dateLabel.setText("-"); - - addCloseKeyShortcut(() -> getStage().close()); } @Override @@ -159,7 +160,9 @@ public class ProjectManagerDialog extends ViewController implements Notification stage.setHeight(400); stage.setTitle(Localization.getString(Strings.UI_Dialog_ProjectManager_Title)); - Profile.currentProfile().currentLayout().applyCss(getStage()); + stage.initModality(Modality.WINDOW_MODAL); + + Profile.currentProfile().currentLayout().applyCss(stage); } @FXML @@ -171,7 +174,7 @@ public class ProjectManagerDialog extends ViewController implements Notification Stage dialog = (Stage) alert.getDialogPane().getScene().getWindow(); PlayPadMain.stageIcon.ifPresent(dialog.getIcons()::add); - alert.initOwner(getStage()); + alert.initOwner(getContainingWindow()); alert.initModality(Modality.WINDOW_MODAL); alert.showAndWait().filter(item -> item == ButtonType.OK).ifPresent(item -> @@ -188,12 +191,12 @@ public class ProjectManagerDialog extends ViewController implements Notification @FXML private void cancelButtonHandler(ActionEvent event) { cancel = true; - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } @FXML private void openButtonHandler(ActionEvent event) { - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } @FXML @@ -220,8 +223,8 @@ public class ProjectManagerDialog extends ViewController implements Notification @FXML private void newButtonHandler(ActionEvent event) { - NewProjectDialog dialog = new NewProjectDialog(getStage()); - dialog.getStage().showAndWait(); + NewProjectDialog dialog = new NewProjectDialog(getContainingWindow()); + dialog.getStageContainer().ifPresent(NVCStage::showAndWait); Project project = dialog.getProject(); projectList.getItems().add(project.getProjectReference()); @@ -244,11 +247,11 @@ public class ProjectManagerDialog extends ViewController implements Notification private void importButtonHandler(ActionEvent event) { FileChooser chooser = new FileChooser(); chooser.getExtensionFilters().add(new ExtensionFilter(Localization.getString(Strings.File_Filter_ZIP), PlayPadMain.projectZIPType)); - File file = chooser.showOpenDialog(getStage()); + File file = chooser.showOpenDialog(getContainingWindow()); if (file != null) { Path zipFile = file.toPath(); try { - ImportDialog inportDialog = ImportDialog.getInstance(getStage()); + ImportDialog inportDialog = ImportDialog.getInstance(getContainingWindow()); ProjectReference ref = ProjectImporter.importProject(zipFile, inportDialog, inportDialog); if (ref != null) { projectList.getItems().add(ref); @@ -277,12 +280,12 @@ public class ProjectManagerDialog extends ViewController implements Notification } } - ProjectExportDialog dialog = new ProjectExportDialog(selectedProject, getStage(), this); - dialog.getStage().show(); + ProjectExportDialog dialog = new ProjectExportDialog(selectedProject, getContainingWindow(), this); + dialog.getStageContainer().ifPresent(NVCStage::show); } public Optional<ProjectReference> showAndWait() { - getStage().showAndWait(); + getStageContainer().ifPresent(NVCStage::showAndWait); if (!cancel) { if (getSelecteItem() != null) { if (currentProject.getProjectReference() != getSelecteItem()) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/SaveDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/SaveDialog.java index 1cff79c5..1248e78c 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/SaveDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/SaveDialog.java @@ -2,7 +2,7 @@ package de.tobias.playpad.viewcontroller.dialog; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; -import de.tobias.utils.ui.AdvancedDialog; +import de.tobias.utils.nui.AdvancedDialog; import de.tobias.utils.util.Localization; import javafx.scene.control.ButtonBar.ButtonData; import javafx.scene.control.ButtonType; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperViewController.java index 064cf731..611dbe9f 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/KeyboardMapperViewController.java @@ -20,7 +20,7 @@ public class KeyboardMapperViewController extends MapperViewController { private KeyboardMapper mapper; public KeyboardMapperViewController() { - super("keyboard", "de/tobias/playpad/assets/view/mapper/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/mapper/", "keyboard", PlayPadMain.getUiResourceBundle()); } @Override @@ -51,7 +51,7 @@ public class KeyboardMapperViewController extends MapperViewController { alert.setContentText(Localization.getString(Strings.Info_Mapper_PressKey)); alert.getButtonTypes().add(ButtonType.CANCEL); - alert.initOwner(getWindow()); + alert.initOwner(getContainingWindow()); boolean result = alert.showInputDialog(); setLabel(); return result; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java index 4dc94293..dc32e4e1 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/mapper/MidiMapperViewController.java @@ -15,6 +15,7 @@ import de.tobias.playpad.midi.Midi; import de.tobias.playpad.midi.MidiListener; import de.tobias.playpad.viewcontroller.option.feedback.DoubleFeedbackViewController; import de.tobias.playpad.viewcontroller.option.feedback.SingleFeedbackViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.util.Localization; import javafx.application.Platform; @@ -38,10 +39,10 @@ public class MidiMapperViewController extends MapperViewController implements Mi private MidiMapper mapper; - private ContentViewController feedbackController; + private NVC feedbackController; public MidiMapperViewController() { - super("midi", "de/tobias/playpad/assets/view/mapper/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/mapper/", "midi", PlayPadMain.getUiResourceBundle()); } @Override @@ -89,7 +90,7 @@ public class MidiMapperViewController extends MapperViewController implements Mi alert.setTitle(Localization.getString(Strings.Mapper_Midi_Name)); alert.setContentText(Localization.getString(Strings.Info_Mapper_PressKey)); alert.getButtonTypes().add(ButtonType.CANCEL); - alert.initOwner(getWindow()); + alert.initOwner(getContainingWindow()); alert.showAndWait().ifPresent(result -> { if (result == ButtonType.CANCEL) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java index 04031530..3ba69413 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java @@ -1,5 +1,6 @@ package de.tobias.playpad.viewcontroller.option.feedback; +import de.tobias.utils.nui.NVC; import org.controlsfx.control.PopOver; import org.controlsfx.control.PopOver.ArrowLocation; @@ -22,7 +23,7 @@ import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.Rectangle; -public class DoubleFeedbackViewController extends ContentViewController { +public class DoubleFeedbackViewController extends NVC { @FXML private HBox defaultColorParent; @FXML private Button colorChooseDefaultButton; @@ -37,7 +38,7 @@ public class DoubleFeedbackViewController extends ContentViewController { private DoubleMidiFeedback feedback; public DoubleFeedbackViewController(DoubleMidiFeedback feedback, DisplayableFeedbackColor[] colors) { - super("doubleFeedback", "de/tobias/playpad/assets/view/option/feedback/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/feedback/", "doubleFeedback", PlayPadMain.getUiResourceBundle()); this.feedback = feedback; MidiDeviceImpl midiDeviceImpl = Midi.getInstance().getMidiDevice(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java index 11cd760a..d4679114 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java @@ -1,6 +1,7 @@ package de.tobias.playpad.viewcontroller.option.feedback; import de.tobias.playpad.action.mididevice.MidiDeviceImpl; +import de.tobias.utils.nui.NVC; import org.controlsfx.control.PopOver; import org.controlsfx.control.PopOver.ArrowLocation; @@ -22,7 +23,7 @@ import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.Rectangle; -public class SingleFeedbackViewController extends ContentViewController { +public class SingleFeedbackViewController extends NVC { @FXML private HBox defaultColorParent; @FXML private Button colorChooseDefaultButton; @@ -33,7 +34,7 @@ public class SingleFeedbackViewController extends ContentViewController { private SingleMidiFeedback feedback; public SingleFeedbackViewController(SingleMidiFeedback feedback, DisplayableFeedbackColor[] colors) { - super("singleFeedback", "de/tobias/playpad/assets/view/option/feedback/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/feedback/", "singleFeedback", PlayPadMain.getUiResourceBundle()); this.feedback = feedback; MidiDeviceImpl midiDeviceImpl = Midi.getInstance().getMidiDevice(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java index 71db68f7..22f9835d 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/GlobalSettingsViewController.java @@ -3,6 +3,8 @@ package de.tobias.playpad.viewcontroller.option.global; import java.util.ArrayList; import java.util.List; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.controlsfx.control.TaskProgressView; import de.tobias.playpad.PlayPadImpl; @@ -31,21 +33,24 @@ import javafx.scene.control.ToggleButton; import javafx.stage.Stage; import javafx.stage.Window; -public class GlobalSettingsViewController extends ViewController implements IGlobalSettingsViewController { +public class GlobalSettingsViewController extends NVC implements IGlobalSettingsViewController { @FXML private TabPane tabPane; @FXML private ToggleButton lockedButton; @FXML private Button finishButton; - protected List<GlobalSettingsTabViewController> tabs = new ArrayList<>(); + private List<GlobalSettingsTabViewController> tabs = new ArrayList<>(); private Runnable onFinish; public GlobalSettingsViewController(Window owner, Runnable onFinish) { - super("globalSettingsView", "de/tobias/playpad/assets/view/option/global/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/global/", "globalSettingsView", PlayPadMain.getUiResourceBundle()); this.onFinish = onFinish; - getStage().initOwner(owner); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + nvcStage.addCloseHook(this::onFinish); + addCloseKeyShortcut(() -> finishButton.fire()); addTab(new GeneralTabViewController(this)); addTab(new KeysTabViewController()); @@ -57,9 +62,6 @@ public class GlobalSettingsViewController extends ViewController implements IGlo @Override public void init() { - // KeyCode - addCloseKeyShortcut(() -> finishButton.fire()); - finishButton.defaultButtonProperty().bind(finishButton.focusedProperty()); } @@ -71,7 +73,7 @@ public class GlobalSettingsViewController extends ViewController implements IGlo stage.setMinHeight(700); stage.setTitle(Localization.getString(Strings.UI_Window_GlobalSettings_Title)); - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } /** @@ -103,16 +105,11 @@ public class GlobalSettingsViewController extends ViewController implements IGlo } } - @Override - public boolean closeRequest() { - return onFinish(); - } - // Button Listener @FXML private void finishButtonHandler(ActionEvent event) { onFinish(); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } /** @@ -122,7 +119,7 @@ public class GlobalSettingsViewController extends ViewController implements IGlo */ private boolean onFinish() { for (GlobalSettingsTabViewController controller : tabs) { - if (controller.validSettings() == false) { + if (!controller.validSettings()) { return false; } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysConflictDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysConflictDialog.java index c0df4125..ea483170 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysConflictDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysConflictDialog.java @@ -13,7 +13,7 @@ import javafx.stage.Stage; public class KeysConflictDialog extends Alert { - public KeysConflictDialog(List<Key> conflicts, KeyCollection collection) { + KeysConflictDialog(List<Key> conflicts, KeyCollection collection) { super(AlertType.ERROR); String keys = ""; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java index 58f00e1d..7cf73ca6 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/KeysTabViewController.java @@ -49,8 +49,8 @@ public class KeysTabViewController extends GlobalSettingsTabViewController imple private Key currentKey; private ObservableList<Key> keys = FXCollections.observableArrayList(); - public KeysTabViewController() { - super("keysTab", "de/tobias/playpad/assets/view/option/global/", PlayPadMain.getUiResourceBundle()); + KeysTabViewController() { + load("de/tobias/playpad/assets/view/option/global/", "keysTab", PlayPadMain.getUiResourceBundle()); } @Override @@ -147,14 +147,14 @@ public class KeysTabViewController extends GlobalSettingsTabViewController imple Platform.runLater(() -> ((Stage) scene.getWindow()).close()); } else { KeysConflictDialog dialog = new KeysConflictDialog(keyCollection.getConflicts(newKey), keyCollection); - dialog.initOwner(getStage()); + dialog.initOwner(getContainingWindow()); dialog.showAndWait(); } } }); alert.getButtonTypes().add(ButtonType.CANCEL); - alert.initOwner(getWindow()); + alert.initOwner(getContainingWindow()); alert.initModality(Modality.WINDOW_MODAL); Stage alertStage = (Stage) alert.getDialogPane().getScene().getWindow(); PlayPadMain.stageIcon.ifPresent(alertStage.getIcons()::add); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java index 805b15fe..5b5cefa7 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/global/UpdateTabViewController.java @@ -49,8 +49,8 @@ public class UpdateTabViewController extends GlobalSettingsTabViewController { private ProgressIndicator progressIndecator; private Label placeholderLabel; - public UpdateTabViewController() { - super("updateTab", "de/tobias/playpad/assets/view/option/global/", PlayPadMain.getUiResourceBundle()); + UpdateTabViewController() { + load("de/tobias/playpad/assets/view/option/global/", "updateTab", PlayPadMain.getUiResourceBundle()); GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); @@ -117,12 +117,12 @@ public class UpdateTabViewController extends GlobalSettingsTabViewController { @FXML private void updateHandler(ActionEvent event) { - UpdaterDialog dialog = new UpdaterDialog(getStage()); + UpdaterDialog dialog = new UpdaterDialog(getContainingWindow()); dialog.show(); GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); settings.setIgnoreUpdate(false); - + Worker.runLater(() -> { try { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/DesignPadTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/DesignPadTabViewController.java index dc5e02c1..f66f7355 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/DesignPadTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/DesignPadTabViewController.java @@ -30,8 +30,8 @@ public class DesignPadTabViewController extends PadSettingsTabViewController { private Pad pad; - public DesignPadTabViewController(Pad pad) { - super("layoutTab", "de/tobias/playpad/assets/view/option/pad/", PlayPadMain.getUiResourceBundle()); + DesignPadTabViewController(Pad pad) { + load("de/tobias/playpad/assets/view/option/pad/", "layoutTab", PlayPadMain.getUiResourceBundle()); this.pad = pad; } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java index ea172c2a..4df05f42 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java @@ -34,8 +34,8 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { private ChangeListener<Number> volumeListener; - public GeneralPadTabViewController(Pad pad) { - super("generalTab", "de/tobias/playpad/assets/view/option/pad/", PlayPadMain.getUiResourceBundle()); + GeneralPadTabViewController(Pad pad) { + load("de/tobias/playpad/assets/view/option/pad/", "generalTab", PlayPadMain.getUiResourceBundle()); this.pad = pad; if (pad.getStatus() == PadStatus.PLAY || pad.getStatus() == PadStatus.PAUSE) { @@ -102,6 +102,6 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { @FXML private void deleteButtonHandler(ActionEvent event) { pad.clear(); - ((Stage) getStage()).close(); + ((Stage) getContainingWindow()).close(); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java index 3c8167f1..ac805fc4 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java @@ -18,6 +18,8 @@ import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.IPadSettingsViewController; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; @@ -33,12 +35,12 @@ import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; import javafx.stage.Window; -public class PadSettingsViewController extends ViewController implements IPadSettingsViewController { +public class PadSettingsViewController extends NVC implements IPadSettingsViewController { private Pad pad; @FXML private TabPane tabPane; - protected List<PadSettingsTabViewController> tabs = new ArrayList<>(); + private List<PadSettingsTabViewController> tabs = new ArrayList<>(); private Control pathLookupButton; private PathLookupListener pathLookupListener; @@ -46,7 +48,7 @@ public class PadSettingsViewController extends ViewController implements IPadSet @FXML private Button finishButton; public PadSettingsViewController(Pad pad, Window owner) { - super("padSettingsView", "de/tobias/playpad/assets/view/option/pad/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/pad/", "padSettingsView", PlayPadMain.getUiResourceBundle()); this.pad = pad; addTab(new GeneralPadTabViewController(pad)); @@ -72,7 +74,10 @@ public class PadSettingsViewController extends ViewController implements IPadSet setupPathLookupButton(); - getStage().initOwner(owner); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + nvcStage.addCloseHook(this::onFinish); + addCloseKeyShortcut(() -> finishButton.fire()); // Show Current Settings showCurrentSettings(); @@ -127,16 +132,18 @@ public class PadSettingsViewController extends ViewController implements IPadSet } private void setTitle(Pad pad) { + String title; if (pad.getStatus() != PadStatus.EMPTY) { - getStage().setTitle(Localization.getString(Strings.UI_Window_PadSettings_Title, pad.getIndexReadable(), pad.getName())); + title = Localization.getString(Strings.UI_Window_PadSettings_Title, pad.getIndexReadable(), pad.getName()); } else { - getStage().setTitle(Localization.getString(Strings.UI_Window_PadSettings_Title_Empty, pad.getIndexReadable())); + title = Localization.getString(Strings.UI_Window_PadSettings_Title_Empty, pad.getIndexReadable()); } + getStageContainer().ifPresent(nvcStage -> nvcStage.getStage().setTitle(title)); } @Override public void init() { - addCloseKeyShortcut(() -> finishButton.fire()); + } @Override @@ -146,7 +153,7 @@ public class PadSettingsViewController extends ViewController implements IPadSet stage.setMinWidth(650); stage.setMinHeight(550); - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } private void showCurrentSettings() { @@ -168,11 +175,6 @@ public class PadSettingsViewController extends ViewController implements IPadSet return pad; } - @Override - public boolean closeRequest() { - onFinish(); - return true; - } @FXML private void finishButtonHandler(ActionEvent event) { @@ -183,11 +185,12 @@ public class PadSettingsViewController extends ViewController implements IPadSet * Diese Methode wird aufgerufen, wenn das Fenster geschlossen wird (Per X oder Finish Button). Hier geschehen alle Aktionen zum * manuellen Speichern. */ - private void onFinish() { + private boolean onFinish() { // Speichern der einzelen Tabs for (PadSettingsTabViewController controller : tabs) { controller.saveSettings(pad); } - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); + return true; } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java index ef255025..e041148e 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java @@ -17,7 +17,7 @@ public class PathLookupListener implements EventHandler<ActionEvent> { private Alertable alertable; - public PathLookupListener(Alertable alertable) { + PathLookupListener(Alertable alertable) { this.alertable = alertable; } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java index 3bb69488..a774d6f8 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java @@ -26,8 +26,8 @@ public class PlayerPadTabViewController extends PadSettingsTabViewController { private Pad pad; - public PlayerPadTabViewController(Pad pad) { - super("playerTab", "de/tobias/playpad/assets/view/option/pad/", PlayPadMain.getUiResourceBundle()); + PlayerPadTabViewController(Pad pad) { + load("de/tobias/playpad/assets/view/option/pad/", "playerTab", PlayPadMain.getUiResourceBundle()); this.pad = pad; } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/TriggerPadTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/TriggerPadTabViewController.java index 818e56c6..c518bd75 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/TriggerPadTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/TriggerPadTabViewController.java @@ -27,8 +27,8 @@ public class TriggerPadTabViewController extends PadSettingsTabViewController im private Pad pad; - public TriggerPadTabViewController(Pad pad) { - super("triggerTab", "de/tobias/playpad/assets/view/option/pad/", PlayPadMain.getUiResourceBundle()); + TriggerPadTabViewController(Pad pad) { + load("de/tobias/playpad/assets/view/option/pad/", "triggerTab", PlayPadMain.getUiResourceBundle()); this.pad = pad; } 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 69e60440..3527ca74 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 @@ -4,6 +4,7 @@ import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; +import de.tobias.utils.nui.NVC; import org.controlsfx.control.textfield.TextFields; import de.tobias.playpad.PlayPadMain; @@ -25,7 +26,7 @@ import javafx.scene.control.ListView; import javafx.scene.control.TextField; import javafx.util.Callback; -public class CartTriggerViewController extends ContentViewController { +public class CartTriggerViewController extends NVC { @FXML private ComboBox<PadStatus> statusComboBox; @FXML private CheckBox allCartsCheckbox; @@ -36,7 +37,7 @@ public class CartTriggerViewController extends ContentViewController { private CartTriggerItem item; public CartTriggerViewController(CartTriggerItem item) { - super("cartTrigger", "de/tobias/playpad/assets/view/option/pad/trigger/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/pad/trigger/", "cartTrigger", PlayPadMain.getUiResourceBundle()); this.item = item; statusComboBox.setValue(item.getNewStatus()); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerPointViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerPointViewController.java index 6e28be9f..35797532 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerPointViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerPointViewController.java @@ -8,6 +8,7 @@ import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.tigger.TriggerItem; import de.tobias.playpad.tigger.TriggerItemFactory; import de.tobias.playpad.trigger.TriggerDisplayable; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -18,7 +19,7 @@ import javafx.scene.control.Separator; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; -public class TriggerPointViewController extends ContentViewController { +public class TriggerPointViewController extends NVC { @FXML private VBox itemView; @FXML private HBox buttonBox; @@ -26,7 +27,7 @@ public class TriggerPointViewController extends ContentViewController { private TriggerDisplayable triggerWrapper; public TriggerPointViewController(TriggerDisplayable triggerWrapper) { - super("triggerPoint", "de/tobias/playpad/assets/view/option/pad/trigger/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/pad/trigger/", "triggerPoint", PlayPadMain.getUiResourceBundle()); this.triggerWrapper = triggerWrapper; for (TriggerItem item : triggerWrapper.getTrigger().getItems()) @@ -64,11 +65,11 @@ public class TriggerPointViewController extends ContentViewController { TriggerItemFactory connect = PlayPadPlugin.getRegistryCollection().getTriggerItems().getFactory(item.getType()); VBox itemBox = new VBox(14); - ContentViewController contentViewController = connect.getSettingsController(item); - if (contentViewController != null) { - itemBox.getChildren().add(contentViewController.getParent()); + NVC controller = connect.getSettingsController(item); + if (controller != null) { + itemBox.getChildren().add(controller.getParent()); - ContentViewController timeViewController = new TriggerTimeViewController(item); + NVC timeViewController = new TriggerTimeViewController(item); itemBox.getChildren().add(timeViewController.getParent()); Button deleteButton = new Button("", new FontIcon(FontAwesomeType.TRASH)); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerTimeViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerTimeViewController.java index b1215391..18106af7 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerTimeViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/TriggerTimeViewController.java @@ -5,20 +5,21 @@ import java.util.Optional; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PseudoClasses; import de.tobias.playpad.tigger.TriggerItem; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.util.TimeUtils; import javafx.fxml.FXML; import javafx.scene.control.TextField; import javafx.util.Duration; -public class TriggerTimeViewController extends ContentViewController { +public class TriggerTimeViewController extends NVC { @FXML private TextField timeTextField; private TriggerItem item; - public TriggerTimeViewController(TriggerItem item) { - super("triggerTime", "de/tobias/playpad/assets/view/option/pad/trigger/", PlayPadMain.getUiResourceBundle()); + TriggerTimeViewController(TriggerItem item) { + load("de/tobias/playpad/assets/view/option/pad/trigger/", "triggerTime", PlayPadMain.getUiResourceBundle()); this.item = item; timeTextField.setText(String.valueOf(item.getDurationFromPoint().toSeconds())); @@ -29,9 +30,7 @@ public class TriggerTimeViewController extends ContentViewController { timeTextField.textProperty().addListener((a, b, c) -> { Optional<Duration> duration = TimeUtils.parse(c); - if (duration.isPresent()) { - item.setDurationFromPoint(duration.get()); - } + duration.ifPresent(item::setDurationFromPoint); timeTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, !duration.isPresent()); }); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/VolumeTriggerViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/VolumeTriggerViewController.java index 575d7ca4..f1b08ea0 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/VolumeTriggerViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/pad/trigger/VolumeTriggerViewController.java @@ -3,6 +3,7 @@ package de.tobias.playpad.viewcontroller.option.pad.trigger; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.trigger.VolumeTriggerItem; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.util.Localization; import javafx.fxml.FXML; @@ -10,7 +11,7 @@ import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.util.Duration; -public class VolumeTriggerViewController extends ContentViewController { +public class VolumeTriggerViewController extends NVC { @FXML private Slider volumeSlider; @FXML private Label volumeLabel; @@ -21,7 +22,7 @@ public class VolumeTriggerViewController extends ContentViewController { private VolumeTriggerItem item; public VolumeTriggerViewController(VolumeTriggerItem item) { - super("volumeTrigger", "de/tobias/playpad/assets/view/option/pad/trigger/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/pad/trigger/", "volumeTrigger", PlayPadMain.getUiResourceBundle()); this.item = item; volumeSlider.setValue(item.getVolume() * 100.0); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java index 3a4c57e5..c804c7f6 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/AudioTabViewController.java @@ -39,7 +39,7 @@ public class AudioTabViewController extends ProfileSettingsTabViewController imp private boolean changeAudioSettings; public AudioTabViewController(boolean playerActive) { - super("audioTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/profile/", "audioTab", PlayPadMain.getUiResourceBundle()); if (playerActive) { audioTypeComboBox.setDisable(true); 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 19256471..2aaaec43 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/DesignTabViewController.java @@ -27,8 +27,8 @@ public class DesignTabViewController extends ProfileSettingsTabViewController im @FXML private ComboBox<DesignFactory> layoutTypeComboBox; private GlobalDesignViewController globalLayoutViewController; - public DesignTabViewController() { - super("layoutTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); + DesignTabViewController() { + load("de/tobias/playpad/assets/view/option/profile/", "layoutTab", PlayPadMain.getUiResourceBundle()); String layoutType = Profile.currentProfile().getProfileSettings().getLayoutType(); try { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java index 406d947c..5c8bdbdf 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/GeneralTabViewController.java @@ -51,7 +51,7 @@ public class GeneralTabViewController extends GlobalSettingsTabViewController { private Alertable alertable; public GeneralTabViewController(Alertable alertable) { - super("generalTab", "de/tobias/playpad/assets/view/option/global/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/global/", "generalTab", PlayPadMain.getUiResourceBundle()); this.alertable = alertable; calcCacheSize(); @@ -88,7 +88,7 @@ public class GeneralTabViewController extends GlobalSettingsTabViewController { @FXML private void cacheChooseHandler(ActionEvent event) { DirectoryChooser chooser = new DirectoryChooser(); - File folder = chooser.showDialog(getStage()); + File folder = chooser.showDialog(getContainingWindow()); if (folder != null) { Path folderPath = folder.toPath(); GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); 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 ba73394a..4dba0bdc 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MappingTabViewController.java @@ -23,6 +23,7 @@ import de.tobias.playpad.viewcontroller.dialog.MappingListViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.IProfileReloadTask; import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.util.Localization; import javafx.concurrent.Task; @@ -36,23 +37,19 @@ import javafx.scene.layout.VBox; public class MappingTabViewController extends ProfileSettingsTabViewController implements IMappingTabViewController, IProfileReloadTask { - @FXML - private ComboBox<Mapping> mappingComboBox; - @FXML - private Button editMappingsButton; + @FXML private ComboBox<Mapping> mappingComboBox; + @FXML private Button editMappingsButton; - @FXML - private TreeView<ActionDisplayable> treeView; + @FXML private TreeView<ActionDisplayable> treeView; - @FXML - private VBox detailView; + @FXML private VBox detailView; private BaseMapperOverviewViewController baseMapperOverviewViewController; private Mapping oldMapping; private Mapping mapping; - public MappingTabViewController() { - super("mapping", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); + MappingTabViewController() { + load("de/tobias/playpad/assets/view/option/profile/", "mapping", PlayPadMain.getUiResourceBundle()); } @Override @@ -72,7 +69,7 @@ public class MappingTabViewController extends ProfileSettingsTabViewController i detailView.getChildren().clear(); if (c != null) { - ContentViewController controller = c.getValue().getSettingsViewController(); + NVC controller = c.getValue().getSettingsViewController(); if (controller == null) { controller = c.getValue().getActionSettingsViewController(mapping, this); } @@ -112,7 +109,7 @@ public class MappingTabViewController extends ProfileSettingsTabViewController i @FXML private void editMappingsHandler(ActionEvent event) { - MappingListViewController controller = new MappingListViewController(Profile.currentProfile().getMappings(), getWindow()); + MappingListViewController controller = new MappingListViewController(Profile.currentProfile().getMappings(), getContainingWindow()); controller.getStage().showAndWait(); setMappingItemsToList(); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java index 0eb17118..1677a752 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/MidiTabViewController.java @@ -23,8 +23,8 @@ public class MidiTabViewController extends ProfileSettingsTabViewController { @FXML private CheckBox midiActiveCheckBox; @FXML private ComboBox<String> deviceComboBox; - public MidiTabViewController() { - super("midiTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); + MidiTabViewController() { + load("de/tobias/playpad/assets/view/option/profile/", "midiTab", PlayPadMain.getUiResourceBundle()); Info[] data = Midi.getMidiDevices(); // Gerät anzeigen - Doppelte weg diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java index a903758d..b2e6686b 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java @@ -25,8 +25,8 @@ public class PlayerTabViewController extends ProfileSettingsTabViewController { @FXML private VBox fadeContainer; @FXML private ComboBox<TimeMode> timeDisplayComboBox; - public PlayerTabViewController() { - super("playerTab", "de/tobias/playpad/assets/view/option/profile/", PlayPadMain.getUiResourceBundle()); + PlayerTabViewController() { + load("de/tobias/playpad/assets/view/option/profile/", "playerTab", PlayPadMain.getUiResourceBundle()); // Player FadeViewController fadeViewController = new FadeViewController(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java index 235ea3d4..d2658a59 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/profile/ProfileSettingsViewController.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; import de.tobias.playpad.pad.content.ContentFactory; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.controlsfx.control.TaskProgressView; import de.tobias.playpad.PlayPadMain; @@ -36,7 +38,7 @@ import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.Window; -public class ProfileSettingsViewController extends ViewController implements IProfileSettingsViewController { +public class ProfileSettingsViewController extends NVC implements IProfileSettingsViewController { @FXML private TabPane tabPane; @FXML private ToggleButton lockedButton; @@ -47,7 +49,7 @@ public class ProfileSettingsViewController extends ViewController implements IPr private Runnable onFinish; public ProfileSettingsViewController(Midi midiHandler, Screen currentScreen, Window owner, Project project, Runnable onFinish) { - super("settingsView", "de/tobias/playpad/assets/view/option/profile/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/profile/", "settingsView", PlayPadMain.getUiResourceBundle()); this.onFinish = onFinish; boolean activePlayer = project.hasActivePlayers(); @@ -71,7 +73,10 @@ public class ProfileSettingsViewController extends ViewController implements IPr } } - getStage().initOwner(owner); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + nvcStage.addCloseHook(this::onFinish); + addCloseKeyShortcut(() -> finishButton.fire()); // Show Current Settings loadTabs(); @@ -81,9 +86,6 @@ public class ProfileSettingsViewController extends ViewController implements IPr public void init() { ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); - // KeyCode - addCloseKeyShortcut(() -> finishButton.fire()); - // Look Button Listener lockedButton.setGraphic(new FontIcon(FontAwesomeType.LOCK)); lockedButton.setOnAction(e -> @@ -110,7 +112,7 @@ public class ProfileSettingsViewController extends ViewController implements IPr stage.setMinHeight(700); stage.setTitle(Localization.getString(Strings.UI_Window_Settings_Title, Profile.currentProfile().getRef().getName())); - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } /** @@ -140,16 +142,11 @@ public class ProfileSettingsViewController extends ViewController implements IPr } } - @Override - public boolean closeRequest() { - return onFinish(); - } - // Button Listener @FXML private void finishButtonHandler(ActionEvent event) { onFinish(); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } /** @@ -159,7 +156,7 @@ public class ProfileSettingsViewController extends ViewController implements IPr */ private boolean onFinish() { for (ProfileSettingsTabViewController controller : tabs) { - if (controller.validSettings() == false) { + if (!controller.validSettings()) { return false; } } 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 f1fb5142..a935ed20 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java @@ -28,8 +28,8 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController i @FXML private TextField columnTextField; @FXML private TextField rowTextField; - public GeneralTabViewController(Screen currentScreen, Alertable parentController, boolean activePlayer) { - super("generalTab", "de/tobias/playpad/assets/view/option/project/", PlayPadMain.getUiResourceBundle()); + GeneralTabViewController(Screen currentScreen, Alertable parentController, boolean activePlayer) { + load("de/tobias/playpad/assets/view/option/project/", "generalTab", PlayPadMain.getUiResourceBundle()); this.mainWindowScreen = currentScreen; this.parentController = parentController; 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 2e1171a0..aa6177bf 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/PathsTabViewController.java @@ -44,14 +44,14 @@ public class PathsTabViewController extends ProjectSettingsTabViewController imp private transient Optional<Path> currentMediaPath = Optional.empty(); private transient Optional<Path> oldMediaPath = Optional.empty(); - public PathsTabViewController() { - super("pathTab.fxml", "de/tobias/playpad/assets/view/option/project/", PlayPadMain.getUiResourceBundle()); + PathsTabViewController() { + load("de/tobias/playpad/assets/view/option/project/", "pathTab", PlayPadMain.getUiResourceBundle()); } @FXML void mediaPathChooseHandler(ActionEvent event) { DirectoryChooser chooser = new DirectoryChooser(); - File folder = chooser.showDialog(getStage()); + File folder = chooser.showDialog(getContainingWindow()); if (folder != null) { Path path = folder.toPath(); 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 e5bcc710..9d9f6440 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java @@ -3,6 +3,8 @@ package de.tobias.playpad.viewcontroller.option.project; import java.util.ArrayList; import java.util.List; +import de.tobias.utils.nui.NVC; +import de.tobias.utils.nui.NVCStage; import org.controlsfx.control.TaskProgressView; import de.tobias.playpad.PlayPadMain; @@ -30,7 +32,7 @@ import javafx.stage.Screen; import javafx.stage.Stage; import javafx.stage.Window; -public class ProjectSettingsViewController extends ViewController implements IProjectSettingsViewController { +public class ProjectSettingsViewController extends NVC implements IProjectSettingsViewController { @FXML private TabPane tabPane; @FXML private ToggleButton lockedButton; @@ -42,7 +44,7 @@ public class ProjectSettingsViewController extends ViewController implements IPr private Runnable onFinish; public ProjectSettingsViewController(Screen currentScreen, Window owner, Project project, Runnable onFinish) { - super("projectSettingsView", "de/tobias/playpad/assets/view/option/project/", null, PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/view/option/project/", "projectSettingsView", PlayPadMain.getUiResourceBundle()); this.onFinish = onFinish; this.project = project; @@ -51,7 +53,10 @@ public class ProjectSettingsViewController extends ViewController implements IPr addTab(new GeneralTabViewController(currentScreen, this, activePlayer)); addTab(new PathsTabViewController()); - getStage().initOwner(owner); + NVCStage nvcStage = applyViewControllerToStage(); + nvcStage.initOwner(owner); + nvcStage.addCloseHook(this::onFinish); + addCloseKeyShortcut(() -> finishButton.fire()); // Show Current Settings loadTabs(project.getSettings()); @@ -59,9 +64,6 @@ public class ProjectSettingsViewController extends ViewController implements IPr @Override public void init() { - // KeyCode - addCloseKeyShortcut(() -> finishButton.fire()); - finishButton.defaultButtonProperty().bind(finishButton.focusedProperty()); } @@ -73,7 +75,7 @@ public class ProjectSettingsViewController extends ViewController implements IPr stage.setMinHeight(500); stage.setTitle(Localization.getString(Strings.UI_Window_ProjectSettings_Title)); - Profile.currentProfile().currentLayout().applyCss(getStage()); + Profile.currentProfile().currentLayout().applyCss(stage); } /** @@ -94,26 +96,21 @@ public class ProjectSettingsViewController extends ViewController implements IPr } } - @Override - public boolean closeRequest() { - return onFinish(); - } - // Button Listener @FXML private void finishButtonHandler(ActionEvent event) { onFinish(); - getStage().close(); + getStageContainer().ifPresent(NVCStage::close); } /** * Speichert alle Informationen. - * + * * @return <code>true</code>Alle Einstellungen sind Valid. */ private boolean onFinish() { for (ProjectSettingsTabViewController controller : tabs) { - if (controller.validSettings() == false) { + if (!controller.validSettings()) { return false; } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/settings/FadeViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/settings/FadeViewController.java index dfa3c733..2ec711b0 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/settings/FadeViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/settings/FadeViewController.java @@ -3,6 +3,7 @@ package de.tobias.playpad.viewcontroller.settings; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.settings.Fade; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.util.Localization; import javafx.fxml.FXML; @@ -11,7 +12,7 @@ import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.util.Duration; -public class FadeViewController extends ContentViewController { +public class FadeViewController extends NVC { @FXML private Slider fadeInSlider; @FXML private Slider fadeOutSlider; @@ -26,7 +27,7 @@ public class FadeViewController extends ContentViewController { private Fade fade; public FadeViewController() { - super("fadeView", "de/tobias/playpad/assets/settings/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/settings/", "fadeView", PlayPadMain.getUiResourceBundle()); } @Override diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/settings/WarningFeedbackViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/settings/WarningFeedbackViewController.java index f2dca4d8..061512fb 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/settings/WarningFeedbackViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/settings/WarningFeedbackViewController.java @@ -5,6 +5,7 @@ import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.util.Localization; import javafx.fxml.FXML; @@ -12,13 +13,13 @@ import javafx.scene.control.Label; import javafx.scene.control.Slider; import javafx.util.Duration; -public class WarningFeedbackViewController extends ContentViewController { +public class WarningFeedbackViewController extends NVC { @FXML private Slider warningFeedbackTimeSlider; @FXML private Label warningFeedbackTimeLabel; public WarningFeedbackViewController() { - super("warningFeedbackSettingsView", "de/tobias/playpad/assets/settings/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/settings/", "warningFeedbackSettingsView", PlayPadMain.getUiResourceBundle()); ProfileSettings profilSettings = Profile.currentProfile().getProfileSettings(); warningFeedbackTimeSlider.setValue(profilSettings.getWarningFeedback().toSeconds()); @@ -31,7 +32,7 @@ public class WarningFeedbackViewController extends ContentViewController { } public WarningFeedbackViewController(Pad pad) { - super("warningFeedbackSettingsView", "de/tobias/playpad/assets/settings/", PlayPadMain.getUiResourceBundle()); + load("de/tobias/playpad/assets/settings/", "warningFeedbackSettingsView", PlayPadMain.getUiResourceBundle()); } @Override diff --git a/PlayWallCore/src/de/tobias/playpad/Displayable.java b/PlayWallCore/src/de/tobias/playpad/Displayable.java index 232003e4..c050bd0e 100644 --- a/PlayWallCore/src/de/tobias/playpad/Displayable.java +++ b/PlayWallCore/src/de/tobias/playpad/Displayable.java @@ -1,14 +1,15 @@ package de.tobias.playpad; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import javafx.beans.property.StringProperty; import javafx.scene.Node; public interface Displayable { - public StringProperty displayProperty(); + StringProperty displayProperty(); - public default Node getGraphics() { + default Node getGraphics() { return null; } @@ -17,7 +18,7 @@ public interface Displayable { * * @return Einstellungen für dieses Objetkt. */ - public default ContentViewController getSettingsViewController() { + default NVC getSettingsViewController() { return null; } } diff --git a/PlayWallCore/src/de/tobias/playpad/action/ActionDisplayable.java b/PlayWallCore/src/de/tobias/playpad/action/ActionDisplayable.java index 185e80c8..d2a4a821 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/ActionDisplayable.java +++ b/PlayWallCore/src/de/tobias/playpad/action/ActionDisplayable.java @@ -2,6 +2,7 @@ package de.tobias.playpad.action; import de.tobias.playpad.Displayable; import de.tobias.playpad.viewcontroller.IMappingTabViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; /** @@ -25,7 +26,7 @@ public interface ActionDisplayable extends Displayable { * Aktueller ViewController für das Mapping * @return ViewController für den ActionType */ - public default ContentViewController getActionSettingsViewController(Mapping mapping, IMappingTabViewController controller) { + default NVC getActionSettingsViewController(Mapping mapping, IMappingTabViewController controller) { return null; } } diff --git a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperViewController.java b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperViewController.java index d4592c55..d5357735 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/action/mapper/MapperViewController.java @@ -2,6 +2,7 @@ package de.tobias.playpad.action.mapper; import java.util.ResourceBundle; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; /** @@ -12,11 +13,7 @@ import de.tobias.utils.ui.ContentViewController; * @since 5.0.0 * */ -public abstract class MapperViewController extends ContentViewController { - - public MapperViewController(String name, String path, ResourceBundle localization) { - super(name, path, localization); - } +public abstract class MapperViewController extends NVC { public abstract void showFeedback(); diff --git a/PlayWallCore/src/de/tobias/playpad/tigger/TriggerItemFactory.java b/PlayWallCore/src/de/tobias/playpad/tigger/TriggerItemFactory.java index 0932f2ee..98c16c13 100644 --- a/PlayWallCore/src/de/tobias/playpad/tigger/TriggerItemFactory.java +++ b/PlayWallCore/src/de/tobias/playpad/tigger/TriggerItemFactory.java @@ -1,6 +1,7 @@ package de.tobias.playpad.tigger; import de.tobias.playpad.registry.Component; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontIconType; @@ -12,6 +13,6 @@ public abstract class TriggerItemFactory extends Component { public abstract TriggerItem newInstance(Trigger trigger); - public abstract ContentViewController getSettingsController(TriggerItem item); + public abstract NVC getSettingsController(TriggerItem item); } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartDesignViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartDesignViewController.java index 551ca726..c2cb27dd 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartDesignViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/CartDesignViewController.java @@ -3,11 +3,12 @@ package de.tobias.playpad.viewcontroller; import java.util.ResourceBundle; import de.tobias.playpad.design.CartDesign; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; -public abstract class CartDesignViewController extends ContentViewController { +public abstract class CartDesignViewController extends NVC { + + public CartDesignViewController(CartDesign layout) { - public CartDesignViewController(String name, String path, ResourceBundle localization, CartDesign layout) { - super(name, path, localization); } } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalDesignViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalDesignViewController.java index 4681c63e..1428e786 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalDesignViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/GlobalDesignViewController.java @@ -3,11 +3,12 @@ package de.tobias.playpad.viewcontroller; import java.util.ResourceBundle; import de.tobias.playpad.design.GlobalDesign; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; -public abstract class GlobalDesignViewController extends ContentViewController { +public abstract class GlobalDesignViewController extends NVC { + + public GlobalDesignViewController(GlobalDesign layout) { - public GlobalDesignViewController(String name, String path, ResourceBundle localization, GlobalDesign layout) { - super(name, path, localization); } } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/PadSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/PadSettingsTabViewController.java index 6f83c996..4b811edc 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/PadSettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/PadSettingsTabViewController.java @@ -1,14 +1,12 @@ package de.tobias.playpad.viewcontroller; -import java.util.ResourceBundle; - import de.tobias.playpad.pad.Pad; -import de.tobias.utils.ui.ContentViewController; +import de.tobias.utils.nui.NVC; + +public abstract class PadSettingsTabViewController extends NVC { -public abstract class PadSettingsTabViewController extends ContentViewController { + public PadSettingsTabViewController() { - public PadSettingsTabViewController(String name, String path, ResourceBundle localization) { - super(name, path, localization); } public abstract String getName(); diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java index daff746b..09ce9cf0 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/GlobalSettingsTabViewController.java @@ -6,44 +6,36 @@ import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; -public abstract class GlobalSettingsTabViewController extends ContentViewController { +public abstract class GlobalSettingsTabViewController extends NVC { /** * Erstellt einen neuen Tab. - * - * @param name - * Name der FXML - * @param path - * Pfad zu FXML (ohne Dateiname) - * @param localization - * ResourceBundle oder null */ - public GlobalSettingsTabViewController(String name, String path, ResourceBundle localization) { - super(name, path, localization); + public GlobalSettingsTabViewController() { + } /** * Lädt alle Einstellungen vom Model in die GUI. - * - * @param settings - * Aktuelles GlobalSettings + * + * @param settings Aktuelles GlobalSettings */ public abstract void loadSettings(GlobalSettings settings); /** * Speichert alle Änderungen in das Model. - * - * @param settings - * Aktuelles GlobalSettings + * + * @param settings Aktuelles GlobalSettings */ public abstract void saveSettings(GlobalSettings settings); /** * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird * in {@link #reload(Profile, Project, IMainViewController)} ausgeführt. - * + * * @return <code>true</code> Benötigt Reload */ public abstract boolean needReload(); @@ -51,14 +43,14 @@ public abstract class GlobalSettingsTabViewController extends ContentViewControl /** * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht * geschlossen werden. - * + * * @return <code>true</code> Einstellungen erlaubt. <code>false</code> Einstellungen fehlerhaft. */ public abstract boolean validSettings(); /** * Gibt den Namen für den Tab zurück. - * + * * @return Display Name des Tabs. */ public abstract String name(); diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java index 36ac6c87..ea57bb4d 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProfileSettingsTabViewController.java @@ -5,52 +5,42 @@ import java.util.ResourceBundle; import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; /** * Abstract Tab für SettingsViewController. - * + * * @author tobias - * * @since 5.0.0 - * */ -public abstract class ProfileSettingsTabViewController extends ContentViewController { +public abstract class ProfileSettingsTabViewController extends NVC { /** * Erstellt einen neuen Tab. - * - * @param name - * Name der FXML - * @param path - * Pfad zu FXML (ohne Dateiname) - * @param localization - * ResourceBundle oder null */ - public ProfileSettingsTabViewController(String name, String path, ResourceBundle localization) { - super(name, path, localization); + public ProfileSettingsTabViewController() { + } /** * Lädt alle Einstellungen vom Model in die GUI. - * - * @param profile - * Aktuelles Profile + * + * @param profile Aktuelles Profile */ public abstract void loadSettings(Profile profile); /** * Speichert alle Änderungen in das Model. - * - * @param profile - * Aktuelles Profile + * + * @param profile Aktuelles Profile */ public abstract void saveSettings(Profile profile); /** * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird * in {@link #reload(Profile, Project, IMainViewController)} ausgeführt. - * + * * @return <code>true</code> Benötigt Reload */ public abstract boolean needReload(); @@ -58,14 +48,14 @@ public abstract class ProfileSettingsTabViewController extends ContentViewContro /** * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht * geschlossen werden. - * + * * @return <code>true</code> Einstellungen erlaubt. <code>false</code> Einstellungen fehlerhaft. */ public abstract boolean validSettings(); /** * Gibt den Namen für den Tab zurück. - * + * * @return Display Name des Tabs. */ public abstract String name(); diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java index 0f4b33e9..2d6aba60 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/option/ProjectSettingsTabViewController.java @@ -6,53 +6,43 @@ import de.tobias.playpad.project.Project; import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.utils.nui.NVC; import de.tobias.utils.ui.ContentViewController; /** * Abstracter Tab für Project Einstellungen. - * - * @author tobias * - * @since 5.1.0 - * + * @author tobias * @see IProjectSettingsViewController + * @since 5.1.0 */ -public abstract class ProjectSettingsTabViewController extends ContentViewController { +public abstract class ProjectSettingsTabViewController extends NVC { /** * Erstellt einen neuen Tab. - * - * @param name - * Name der FXML - * @param path - * Pfad zu FXML (ohne Dateiname) - * @param localization - * ResourceBundle oder null */ - public ProjectSettingsTabViewController(String name, String path, ResourceBundle localization) { - super(name, path, localization); + public ProjectSettingsTabViewController() { + } /** * Lädt alle Einstellungen vom Model in die GUI. - * - * @param settings - * Aktuelles Project Einstellungen + * + * @param settings Aktuelles Project Einstellungen */ public abstract void loadSettings(ProjectSettings settings); /** * Speichert alle Änderungen in das Model. - * - * @param settings - * Aktuelles Project Einstellungen + * + * @param settings Aktuelles Project Einstellungen */ public abstract void saveSettings(ProjectSettings settings); /** * Gibt <code>true</code> zurück, wenn im Hauptprogramm etwas neu geladen werden muss. Der eigentliche Reload wird * in {@link #reload(Profile, Project, IMainViewController)} ausgeführt. - * + * * @return <code>true</code> Benötigt Reload */ public abstract boolean needReload(); @@ -60,14 +50,14 @@ public abstract class ProjectSettingsTabViewController extends ContentViewContro /** * Prüft ob die eingetragen Einstellungen erlaubt sind. Bei falschen Eingaben können die Einstellungen nicht * geschlossen werden. - * + * * @return <code>true</code> Einstellungen erlaubt. <code>false</code> Einstellungen fehlerhaft. */ public abstract boolean validSettings(); /** * Gibt den Namen für den Tab zurück. - * + * * @return Display Name des Tabs. */ public abstract String name(); diff --git a/PluginMedia/src/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java b/PluginMedia/src/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java index 69ab186c..13a2ebce 100644 --- a/PluginMedia/src/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java +++ b/PluginMedia/src/de/tobias/playpad/mediaplugin/main/impl/MediaSettingsTabViewController.java @@ -35,7 +35,7 @@ public class MediaSettingsTabViewController extends ProfileSettingsTabViewContro private boolean changeSettings = false; public MediaSettingsTabViewController(VideoSettings settings) { - super("settingsPane", "de/tobias/playpad/mediaplugin/assets/", MediaPluginImpl.getInstance().getBundle()); + load("de/tobias/playpad/mediaplugin/assets/", "settingsPane", MediaPluginImpl.getInstance().getBundle()); this.settings = settings; this.bundle = MediaPluginImpl.getInstance().getBundle(); } diff --git a/PluginMedia/src/de/tobias/playpad/mediaplugin/video/VideoPadSettingsTabViewController.java b/PluginMedia/src/de/tobias/playpad/mediaplugin/video/VideoPadSettingsTabViewController.java index a430bbb6..8f34482a 100644 --- a/PluginMedia/src/de/tobias/playpad/mediaplugin/video/VideoPadSettingsTabViewController.java +++ b/PluginMedia/src/de/tobias/playpad/mediaplugin/video/VideoPadSettingsTabViewController.java @@ -10,8 +10,8 @@ public class VideoPadSettingsTabViewController extends PadSettingsTabViewControl @FXML private CheckBox lastFrameCheckBox; - public VideoPadSettingsTabViewController() { - super("settingsPadPane", "de/tobias/playpad/mediaplugin/assets/", MediaPluginImpl.getInstance().getBundle()); + VideoPadSettingsTabViewController() { + load("de/tobias/playpad/mediaplugin/assets/", "settingsPadPane", MediaPluginImpl.getInstance().getBundle()); } @Override -- GitLab