diff --git a/src/main/java/io/github/dsheirer/controller/channel/ChannelAutoStartFrame.java b/src/main/java/io/github/dsheirer/controller/channel/ChannelAutoStartFrame.java
index 73689065..24bfec60 100644
--- a/src/main/java/io/github/dsheirer/controller/channel/ChannelAutoStartFrame.java
+++ b/src/main/java/io/github/dsheirer/controller/channel/ChannelAutoStartFrame.java
@@ -1,7 +1,6 @@
/*
- * ******************************************************************************
- * sdrtrunk
- * Copyright (C) 2014-2018 Dennis Sheirer
+ * *****************************************************************************
+ * Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,22 +14,13 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
- * *****************************************************************************
+ * ****************************************************************************
*/
package io.github.dsheirer.controller.channel;
+import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.util.ThreadPool;
-import net.miginfocom.swing.MigLayout;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
@@ -41,12 +31,21 @@ import java.util.List;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
+import net.miginfocom.swing.MigLayout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
public class ChannelAutoStartFrame extends JFrame
{
private final static Logger mLog = LoggerFactory.getLogger(ChannelAutoStartFrame.class);
- private static final int COUNTDOWN_SECONDS = 10;
private Listener mChannelEventListener;
private List mChannels;
@@ -55,7 +54,7 @@ public class ChannelAutoStartFrame extends JFrame
private JButton mCancelButton;
private JTable mChannelTable;
private AtomicBoolean mChannelsStarted = new AtomicBoolean();
-
+ private int mAutoStartTimeoutSeconds;
private ScheduledFuture> mTimerFuture;
/**
@@ -66,10 +65,12 @@ public class ChannelAutoStartFrame extends JFrame
* @param listener to receive channel start/enable request(s)
* @param channels to auto-start
*/
- public ChannelAutoStartFrame(Listener listener, List channels)
+ public ChannelAutoStartFrame(Listener listener, List channels, UserPreferences userPreferences)
{
mChannelEventListener = listener;
mChannels = channels;
+ mAutoStartTimeoutSeconds = userPreferences.getApplicationPreference().getChannelAutoStartTimeout();
+
init();
EventQueue.invokeLater(() -> {
@@ -100,7 +101,7 @@ public class ChannelAutoStartFrame extends JFrame
"[][][grow,fill][]"));
panel.add(new JLabel("The following channels will be automatically"), "span");
- mCountdownLabel = new JLabel(getCountdownText(COUNTDOWN_SECONDS));
+ mCountdownLabel = new JLabel(getCountdownText(mAutoStartTimeoutSeconds));
panel.add(mCountdownLabel, "span");
panel.add(new JScrollPane(getChannelTable()), "span");
@@ -220,7 +221,7 @@ public class ChannelAutoStartFrame extends JFrame
*/
public class CountdownTimer implements Runnable
{
- private int mCount = COUNTDOWN_SECONDS;
+ private int mCount = mAutoStartTimeoutSeconds;
@Override
public void run()
diff --git a/src/main/java/io/github/dsheirer/gui/SDRTrunk.java b/src/main/java/io/github/dsheirer/gui/SDRTrunk.java
index 15a08d8e..0887b645 100644
--- a/src/main/java/io/github/dsheirer/gui/SDRTrunk.java
+++ b/src/main/java/io/github/dsheirer/gui/SDRTrunk.java
@@ -313,7 +313,7 @@ public class SDRTrunk implements Listener
}
else
{
- new ChannelAutoStartFrame(mPlaylistManager.getChannelProcessingManager(), channels);
+ new ChannelAutoStartFrame(mPlaylistManager.getChannelProcessingManager(), channels, mUserPreferences);
}
}
}
diff --git a/src/main/java/io/github/dsheirer/gui/preference/PreferenceEditorFactory.java b/src/main/java/io/github/dsheirer/gui/preference/PreferenceEditorFactory.java
index b2dd2ec8..6414411b 100644
--- a/src/main/java/io/github/dsheirer/gui/preference/PreferenceEditorFactory.java
+++ b/src/main/java/io/github/dsheirer/gui/preference/PreferenceEditorFactory.java
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
- * Copyright (C) 2014-2022 Dennis Sheirer
+ * Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
package io.github.dsheirer.gui.preference;
+import io.github.dsheirer.gui.preference.application.ApplicationPreferenceEditor;
import io.github.dsheirer.gui.preference.calibration.VectorCalibrationPreferenceEditor;
import io.github.dsheirer.gui.preference.decoder.JmbeLibraryPreferenceEditor;
import io.github.dsheirer.gui.preference.directory.DirectoryPreferenceEditor;
@@ -39,6 +40,8 @@ public class PreferenceEditorFactory
{
switch(preferenceEditorType)
{
+ case APPLICATION:
+ return new ApplicationPreferenceEditor(userPreferences);
case AUDIO_DUPLICATE_CALL_DETECTION:
return new DuplicateCallPreferenceEditor(userPreferences);
case AUDIO_MP3:
diff --git a/src/main/java/io/github/dsheirer/gui/preference/PreferenceEditorType.java b/src/main/java/io/github/dsheirer/gui/preference/PreferenceEditorType.java
index 22b268ef..4adfdd2e 100644
--- a/src/main/java/io/github/dsheirer/gui/preference/PreferenceEditorType.java
+++ b/src/main/java/io/github/dsheirer/gui/preference/PreferenceEditorType.java
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
- * Copyright (C) 2014-2022 Dennis Sheirer
+ * Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@ package io.github.dsheirer.gui.preference;
*/
public enum PreferenceEditorType
{
+ APPLICATION("Application"),
CHANNEL_EVENT("Channel Events"),
DIRECTORY("Directories"),
JMBE_LIBRARY("JMBE Audio Library"),
diff --git a/src/main/java/io/github/dsheirer/gui/preference/UserPreferencesEditor.java b/src/main/java/io/github/dsheirer/gui/preference/UserPreferencesEditor.java
index 37add324..e98aafe7 100644
--- a/src/main/java/io/github/dsheirer/gui/preference/UserPreferencesEditor.java
+++ b/src/main/java/io/github/dsheirer/gui/preference/UserPreferencesEditor.java
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
- * Copyright (C) 2014-2022 Dennis Sheirer
+ * Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,6 +165,11 @@ public class UserPreferencesEditor extends BorderPane
{
TreeItem treeRoot = new TreeItem<>("Root node");
+ TreeItem applicationItem = new TreeItem<>("Application");
+ applicationItem.getChildren().add(new TreeItem(PreferenceEditorType.APPLICATION));
+ treeRoot.getChildren().add(applicationItem);
+ applicationItem.setExpanded(true);
+
TreeItem audioItem = new TreeItem<>("Audio");
audioItem.getChildren().add(new TreeItem(PreferenceEditorType.AUDIO_DUPLICATE_CALL_DETECTION));
audioItem.getChildren().add(new TreeItem(PreferenceEditorType.AUDIO_MP3));
diff --git a/src/main/java/io/github/dsheirer/gui/preference/application/ApplicationPreferenceEditor.java b/src/main/java/io/github/dsheirer/gui/preference/application/ApplicationPreferenceEditor.java
new file mode 100644
index 00000000..0a8bac21
--- /dev/null
+++ b/src/main/java/io/github/dsheirer/gui/preference/application/ApplicationPreferenceEditor.java
@@ -0,0 +1,94 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) 2014-2023 Dennis Sheirer
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * ****************************************************************************
+ */
+
+package io.github.dsheirer.gui.preference.application;
+
+import io.github.dsheirer.preference.UserPreferences;
+import io.github.dsheirer.preference.application.ApplicationPreference;
+import javafx.geometry.HPos;
+import javafx.geometry.Insets;
+import javafx.scene.control.Label;
+import javafx.scene.control.Spinner;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+
+
+/**
+ * Preference settings for application
+ */
+public class ApplicationPreferenceEditor extends HBox
+{
+ private ApplicationPreference mApplicationPreference;
+ private GridPane mEditorPane;
+ private Label mAutoStartTimeoutLabel;
+ private Spinner mTimeoutSpinner;
+
+ /**
+ * Constructs an instance
+ * @param userPreferences for obtaining reference to preference.
+ */
+ public ApplicationPreferenceEditor(UserPreferences userPreferences)
+ {
+ mApplicationPreference = userPreferences.getApplicationPreference();
+ getChildren().add(getEditorPane());
+ }
+
+ private GridPane getEditorPane()
+ {
+ if(mEditorPane == null)
+ {
+ int row = 0;
+ mEditorPane = new GridPane();
+ mEditorPane.setVgap(10);
+ mEditorPane.setHgap(10);
+ mEditorPane.setPadding(new Insets(10, 10, 10, 10));
+ GridPane.setHalignment(getAutoStartTimeoutLabel(), HPos.RIGHT);
+ mEditorPane.add(getAutoStartTimeoutLabel(), 0, row);
+ mEditorPane.add(getTimeoutSpinner(), 1, row);
+ mEditorPane.add(new Label("seconds"), 2, row);
+ }
+
+ return mEditorPane;
+ }
+
+ private Label getAutoStartTimeoutLabel()
+ {
+ if(mAutoStartTimeoutLabel == null)
+ {
+ mAutoStartTimeoutLabel = new Label("Channel Auto-Start Timeout");
+ }
+
+ return mAutoStartTimeoutLabel;
+ }
+
+ /**
+ * Spinner to select channel auto-start timeout value in range 0-30 seconds.
+ * @return spinner
+ */
+ private Spinner getTimeoutSpinner()
+ {
+ if(mTimeoutSpinner == null)
+ {
+ mTimeoutSpinner = new Spinner<>(0, 30, mApplicationPreference.getChannelAutoStartTimeout(), 1);
+ mTimeoutSpinner.valueProperty().addListener((observable, oldValue, newValue) -> mApplicationPreference.setChannelAutoStartTimeout(newValue));
+ }
+
+ return mTimeoutSpinner;
+ }
+}
diff --git a/src/main/java/io/github/dsheirer/preference/PreferenceType.java b/src/main/java/io/github/dsheirer/preference/PreferenceType.java
index 355ff838..813c3cf3 100644
--- a/src/main/java/io/github/dsheirer/preference/PreferenceType.java
+++ b/src/main/java/io/github/dsheirer/preference/PreferenceType.java
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
- * Copyright (C) 2014-2022 Dennis Sheirer
+ * Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@ package io.github.dsheirer.preference;
*/
public enum PreferenceType
{
+ APPLICATION,
CALIBRATION,
DECODE_EVENT,
DIRECTORY,
diff --git a/src/main/java/io/github/dsheirer/preference/UserPreferences.java b/src/main/java/io/github/dsheirer/preference/UserPreferences.java
index 3f10b316..42b5e26f 100644
--- a/src/main/java/io/github/dsheirer/preference/UserPreferences.java
+++ b/src/main/java/io/github/dsheirer/preference/UserPreferences.java
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
- * Copyright (C) 2014-2022 Dennis Sheirer
+ * Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
package io.github.dsheirer.preference;
import io.github.dsheirer.eventbus.MyEventBus;
+import io.github.dsheirer.preference.application.ApplicationPreference;
import io.github.dsheirer.preference.calibration.VectorCalibrationPreference;
import io.github.dsheirer.preference.decoder.JmbeLibraryPreference;
import io.github.dsheirer.preference.directory.DirectoryPreference;
@@ -55,7 +56,7 @@ import io.github.dsheirer.sample.Listener;
*/
public class UserPreferences implements Listener
{
- private VectorCalibrationPreference mVectorCalibrationPreference;
+ private ApplicationPreference mApplicationPreference;
private ChannelMultiFrequencyPreference mChannelMultiFrequencyPreference;
private DecodeEventPreference mDecodeEventPreference;
private DirectoryPreference mDirectoryPreference;
@@ -68,6 +69,7 @@ public class UserPreferences implements Listener
private RecordPreference mRecordPreference;
private TalkgroupFormatPreference mTalkgroupFormatPreference;
private TunerPreference mTunerPreference;
+ private VectorCalibrationPreference mVectorCalibrationPreference;
private SwingPreference mSwingPreference = new SwingPreference();
private JavaFxPreferences mJavaFxPreferences = new JavaFxPreferences();
@@ -80,6 +82,19 @@ public class UserPreferences implements Listener
loadPreferenceTypes();
}
+ /**
+ * Application general/miscellaneous preferences.
+ * @return application preferences.
+ */
+ public ApplicationPreference getApplicationPreference()
+ {
+ return mApplicationPreference;
+ }
+
+ /**
+ * Vector/SIMD calibration preferences.
+ * @return vector calibration preferences.
+ */
public VectorCalibrationPreference getVectorCalibrationPreference()
{
return mVectorCalibrationPreference;
@@ -203,7 +218,7 @@ public class UserPreferences implements Listener
*/
private void loadPreferenceTypes()
{
- mVectorCalibrationPreference = new VectorCalibrationPreference(this::receive);
+ mApplicationPreference = new ApplicationPreference(this::receive);
mChannelMultiFrequencyPreference = new ChannelMultiFrequencyPreference(this::receive);
mDecodeEventPreference = new DecodeEventPreference(this::receive);
mDirectoryPreference = new DirectoryPreference(this::receive);
@@ -216,6 +231,7 @@ public class UserPreferences implements Listener
mRecordPreference = new RecordPreference(this::receive);
mTalkgroupFormatPreference = new TalkgroupFormatPreference(this::receive);
mTunerPreference = new TunerPreference(this::receive);
+ mVectorCalibrationPreference = new VectorCalibrationPreference(this::receive);
}
/**
diff --git a/src/main/java/io/github/dsheirer/preference/application/ApplicationPreference.java b/src/main/java/io/github/dsheirer/preference/application/ApplicationPreference.java
new file mode 100644
index 00000000..17c9a871
--- /dev/null
+++ b/src/main/java/io/github/dsheirer/preference/application/ApplicationPreference.java
@@ -0,0 +1,80 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) 2014-2023 Dennis Sheirer
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * ****************************************************************************
+ */
+
+package io.github.dsheirer.preference.application;
+
+import io.github.dsheirer.preference.Preference;
+import io.github.dsheirer.preference.PreferenceType;
+import io.github.dsheirer.sample.Listener;
+import java.util.prefs.Preferences;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * General/Miscellaneous preferences
+ */
+public class ApplicationPreference extends Preference
+{
+ private static final String PREFERENCE_KEY_CHANNEL_AUTO_START_TIMEOUT = "channel.auto.start.timeout";
+
+ private final static Logger mLog = LoggerFactory.getLogger(ApplicationPreference.class);
+ private Preferences mPreferences = Preferences.userNodeForPackage(ApplicationPreference.class);
+ private Integer mChannelAutoStartTimeout;
+
+ /**
+ * Constructs an instance
+ * @param updateListener to receive notifications that a preference has been updated
+ */
+ public ApplicationPreference(Listener updateListener)
+ {
+ super(updateListener);
+ }
+
+ @Override
+ public PreferenceType getPreferenceType()
+ {
+ return PreferenceType.APPLICATION;
+ }
+
+
+ /**
+ * Channel auto-start timeout. This is the countdown in seconds to allow the user to cancel the channel auto-start.
+ * @return timeout in seconds.
+ */
+ public int getChannelAutoStartTimeout()
+ {
+ if(mChannelAutoStartTimeout == null)
+ {
+ mChannelAutoStartTimeout = mPreferences.getInt(PREFERENCE_KEY_CHANNEL_AUTO_START_TIMEOUT, 10);
+ }
+
+ return mChannelAutoStartTimeout;
+ }
+
+ /**
+ * Sets the channel auto-start timeout seconds value.
+ * @param timeout in seconds.
+ */
+ public void setChannelAutoStartTimeout(int timeout)
+ {
+ mChannelAutoStartTimeout = timeout;
+ mPreferences.putInt(PREFERENCE_KEY_CHANNEL_AUTO_START_TIMEOUT, timeout);
+ notifyPreferenceUpdated();
+ }
+}