|
| 1 | +// Written by Jürgen Moßgraber - mossgrabers.de |
| 2 | +// (c) 2019-2026 |
| 3 | +// Licensed under LGPLv3 - http://www.gnu.org/licenses/lgpl-3.0.txt |
| 4 | + |
| 5 | +package de.mossgrabers.convertwithmoss.format.akai; |
| 6 | + |
| 7 | +import java.util.ArrayList; |
| 8 | +import java.util.Arrays; |
| 9 | +import java.util.List; |
| 10 | +import java.util.Map; |
| 11 | + |
| 12 | +import de.mossgrabers.convertwithmoss.core.INotifier; |
| 13 | +import de.mossgrabers.convertwithmoss.core.settings.MetadataSettingsUI; |
| 14 | +import de.mossgrabers.tools.ui.BasicConfig; |
| 15 | +import de.mossgrabers.tools.ui.panel.BoxPanel; |
| 16 | +import javafx.geometry.Orientation; |
| 17 | +import javafx.scene.Node; |
| 18 | +import javafx.scene.control.CheckBox; |
| 19 | +import javafx.scene.control.ScrollPane; |
| 20 | + |
| 21 | + |
| 22 | +/** |
| 23 | + * Settings of the MPC Key-group detector. |
| 24 | + * |
| 25 | + * @author Jürgen Moßgraber |
| 26 | + */ |
| 27 | +public class MPCKeygroupDetectorUI extends MetadataSettingsUI |
| 28 | +{ |
| 29 | + private static final String MPC_IGNORE_LOOPS = "MPCIgnoreLoops"; |
| 30 | + |
| 31 | + private CheckBox ignoreLoopsCheckBox; |
| 32 | + private boolean ignoreLoops; |
| 33 | + |
| 34 | + |
| 35 | + /** |
| 36 | + * Constructor. |
| 37 | + * |
| 38 | + * @param prefix The prefix to use for the properties tags |
| 39 | + */ |
| 40 | + public MPCKeygroupDetectorUI (final String prefix) |
| 41 | + { |
| 42 | + super (prefix); |
| 43 | + } |
| 44 | + |
| 45 | + |
| 46 | + /** {@inheritDoc} */ |
| 47 | + @Override |
| 48 | + public Node getEditPane () |
| 49 | + { |
| 50 | + final BoxPanel panel = new BoxPanel (Orientation.VERTICAL); |
| 51 | + |
| 52 | + //////////////////////////////////////////////////////////// |
| 53 | + // Options |
| 54 | + |
| 55 | + panel.createSeparator ("@IDS_MPC_OPTIONS"); |
| 56 | + |
| 57 | + this.ignoreLoopsCheckBox = panel.createCheckBox ("@IDS_MPC_IGNORE_LOOPS", "@IDS_MPC_IGNORE_LOOPS_TOOLTIP"); |
| 58 | + |
| 59 | + //////////////////////////////////////////////////////////// |
| 60 | + // Metadata |
| 61 | + |
| 62 | + this.addTo (panel); |
| 63 | + this.getSeparator ().getStyleClass ().add ("titled-separator-pane"); |
| 64 | + |
| 65 | + final ScrollPane scrollPane = new ScrollPane (panel.getPane ()); |
| 66 | + scrollPane.fitToWidthProperty ().set (true); |
| 67 | + scrollPane.fitToHeightProperty ().set (true); |
| 68 | + return scrollPane; |
| 69 | + } |
| 70 | + |
| 71 | + |
| 72 | + /** {@inheritDoc} */ |
| 73 | + @Override |
| 74 | + public void saveSettings (final BasicConfig config) |
| 75 | + { |
| 76 | + super.saveSettings (config); |
| 77 | + |
| 78 | + config.setBoolean (MPC_IGNORE_LOOPS, this.ignoreLoopsCheckBox.isSelected ()); |
| 79 | + } |
| 80 | + |
| 81 | + |
| 82 | + /** {@inheritDoc} */ |
| 83 | + @Override |
| 84 | + public void loadSettings (final BasicConfig config) |
| 85 | + { |
| 86 | + super.loadSettings (config); |
| 87 | + |
| 88 | + this.ignoreLoopsCheckBox.setSelected (config.getBoolean (MPC_IGNORE_LOOPS, false)); |
| 89 | + } |
| 90 | + |
| 91 | + |
| 92 | + /** {@inheritDoc} */ |
| 93 | + @Override |
| 94 | + public boolean checkSettingsUI (final INotifier notifier) |
| 95 | + { |
| 96 | + if (!super.checkSettingsUI (notifier)) |
| 97 | + return false; |
| 98 | + |
| 99 | + this.ignoreLoops = this.ignoreLoopsCheckBox.isSelected (); |
| 100 | + return true; |
| 101 | + } |
| 102 | + |
| 103 | + |
| 104 | + /** {@inheritDoc} */ |
| 105 | + @Override |
| 106 | + public boolean checkSettingsCLI (final INotifier notifier, final Map<String, String> parameters) |
| 107 | + { |
| 108 | + if (!super.checkSettingsCLI (notifier, parameters)) |
| 109 | + return false; |
| 110 | + |
| 111 | + String value = parameters.remove (MPC_IGNORE_LOOPS); |
| 112 | + this.ignoreLoops = "1".equals (value); |
| 113 | + return true; |
| 114 | + } |
| 115 | + |
| 116 | + |
| 117 | + /** {@inheritDoc} */ |
| 118 | + @Override |
| 119 | + public String [] getCLIParameterNames () |
| 120 | + { |
| 121 | + final List<String> parameterNames = new ArrayList<> (Arrays.asList (super.getCLIParameterNames ())); |
| 122 | + parameterNames.add (MPC_IGNORE_LOOPS); |
| 123 | + return parameterNames.toArray (new String [parameterNames.size ()]); |
| 124 | + } |
| 125 | + |
| 126 | + |
| 127 | + /** |
| 128 | + * Should unsupported attributes be logged? |
| 129 | + * |
| 130 | + * @return True if they should be logged |
| 131 | + */ |
| 132 | + public boolean ignoreLoops () |
| 133 | + { |
| 134 | + return this.ignoreLoops; |
| 135 | + } |
| 136 | +} |
0 commit comments