#1731 Adds application status bar with progress indicators for CPU, memory and disk space (event logs / recordings) usage. Updates user preferences to include threshold settings in the directories editor for max size for event logs and recordings.

This commit is contained in:
Dennis Sheirer
2023-11-12 07:19:10 -05:00
parent e79f2af759
commit dba50744a9
7 changed files with 561 additions and 25 deletions

View File

@@ -41,6 +41,8 @@ import io.github.dsheirer.icon.IconModel;
import io.github.dsheirer.jmbe.JmbeEditor;
import io.github.dsheirer.jmbe.JmbeEditorRequest;
import io.github.dsheirer.module.log.EventLogManager;
import io.github.dsheirer.monitor.ResourceMonitor;
import io.github.dsheirer.monitor.StatusBox;
import io.github.dsheirer.playlist.PlaylistManager;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.source.tuner.manager.TunerManager;
@@ -90,6 +92,7 @@ public class JavaFxWindowManager extends Application
private Stage mPlaylistStage;
private Stage mUserPreferencesStage;
private Stage mRecordingViewerStage;
private JFXPanel mStatusPanel;
/**
* Constructs an instance. Note: this constructor is used for Swing applications.
@@ -118,6 +121,27 @@ public class JavaFxWindowManager extends Application
setup();
}
/**
* Creates or accesses the JavaFX status panel, used by the main application GUI.
* @param resourceMonitor for statistics
* @return JFXPanel accessible on Swing thread that delegates JavaFX scene creation to the FX event thread.
*/
public JFXPanel getStatusPanel(ResourceMonitor resourceMonitor)
{
if(mStatusPanel == null)
{
mStatusPanel = new JFXPanel();
//JFXPanel has to be populated on the FX event thread
Platform.runLater(() -> {
Scene scene = new Scene(new StatusBox(resourceMonitor));
mStatusPanel.setScene(scene);
});
}
return mStatusPanel;
}
private void setup()
{
//Register this class to receive events via each method annotated with @Subscribe

View File

@@ -43,6 +43,7 @@ import io.github.dsheirer.icon.IconModel;
import io.github.dsheirer.log.ApplicationLog;
import io.github.dsheirer.map.MapService;
import io.github.dsheirer.module.log.EventLogManager;
import io.github.dsheirer.monitor.ResourceMonitor;
import io.github.dsheirer.playlist.PlaylistManager;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.properties.SystemProperties;
@@ -68,7 +69,6 @@ import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -82,6 +82,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Optional;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.control.ButtonType;
import jiconfont.icons.font_awesome.FontAwesome;
import jiconfont.swing.IconFontSwing;
@@ -128,6 +129,8 @@ public class SDRTrunk implements Listener<TunerEvent>
private UserPreferences mUserPreferences = new UserPreferences();
private TunerManager mTunerManager;
private ApplicationLog mApplicationLog;
private ResourceMonitor mResourceMonitor;
private JFXPanel mStatusPanel;
private String mTitle;
@@ -141,6 +144,8 @@ public class SDRTrunk implements Listener<TunerEvent>
mApplicationLog = new ApplicationLog(mUserPreferences);
mApplicationLog.start();
mResourceMonitor = new ResourceMonitor(mUserPreferences);
String operatingSystem = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if(operatingSystem.contains("mac") || operatingSystem.contains("nux"))
@@ -316,7 +321,7 @@ public class SDRTrunk implements Listener<TunerEvent>
*/
private void initGUI()
{
mMainGui.setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]"));
mMainGui.setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill][]"));
/**
* Setup main JFrame window
@@ -382,6 +387,10 @@ public class SDRTrunk implements Listener<TunerEvent>
mMainGui.add(mSplitPane, "cell 0 0,span,grow");
mResourceMonitor.start();
mStatusPanel = mJavaFxWindowManager.getStatusPanel(mResourceMonitor);
mMainGui.add(mStatusPanel, "span,growx");
/**
* Menu items
*/
@@ -392,14 +401,9 @@ public class SDRTrunk implements Listener<TunerEvent>
menuBar.add(fileMenu);
JMenuItem exitMenu = new JMenuItem("Exit");
exitMenu.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
processShutdown();
System.exit(0);
}
exitMenu.addActionListener(event -> {
processShutdown();
System.exit(0);
}
);
@@ -571,6 +575,7 @@ public class SDRTrunk implements Listener<TunerEvent>
mLog.info("Stopping channels ...");
mPlaylistManager.getChannelProcessingManager().shutdown();
mAudioRecordingManager.stop();
mResourceMonitor.stop();
mLog.info("Stopping spectral display ...");
mSpectralPanel.clearTuner();
@@ -742,14 +747,9 @@ public class SDRTrunk implements Listener<TunerEvent>
setSelected(mBroadcastStatusPanel != null);
addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
toggleBroadcastStatusPanelVisibility();
setSelected(mBroadcastStatusVisible);
}
addActionListener(e -> {
toggleBroadcastStatusPanelVisibility();
setSelected(mBroadcastStatusVisible);
});
}
}

View File

@@ -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 @@ import io.github.dsheirer.eventbus.MyEventBus;
import io.github.dsheirer.preference.PreferenceType;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.preference.directory.DirectoryPreference;
import java.io.File;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
@@ -31,6 +32,7 @@ import javafx.geometry.Orientation;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Separator;
import javafx.scene.control.Spinner;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
@@ -39,8 +41,6 @@ import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
/**
* Preference settings for channel event view
@@ -97,6 +97,9 @@ public class DirectoryPreferenceEditor extends HBox
private Button mResetStreamingButton;
private Label mStreamingPathLabel;
private Spinner<Integer> mRecordingSpinner;
private Spinner<Integer> mEventLogSpinner;
public DirectoryPreferenceEditor(UserPreferences userPreferences)
{
mDirectoryPreference = userPreferences.getDirectoryPreference();
@@ -247,11 +250,57 @@ public class DirectoryPreferenceEditor extends HBox
GridPane.setMargin(getResetStreamingButton(), new Insets(2, 0, 2, 0));
mEditorPane.add(getResetStreamingButton(), 3, row++);
Label monitorLabel = new Label("File storage usage monitoring - maximum size thresholds (MB)");
GridPane.setMargin(monitorLabel, new Insets(15, 0, 2, 0));
mEditorPane.add(monitorLabel, 0, row++, 4, 1);
mEditorPane.add(new Separator(Orientation.HORIZONTAL), 0, row++, 4, 1);
mEditorPane.add(new Label("Event Logs"), 0, row);
GridPane.setMargin(getEventLogSpinner(), new Insets(2, 2, 2, 0));
mEditorPane.add(getEventLogSpinner(), 1, row++);
mEditorPane.add(new Label("Recordings"), 0, row);
GridPane.setMargin(getRecordingSpinner(), new Insets(2, 2, 2, 0));
mEditorPane.add(getRecordingSpinner(), 1, row);
}
return mEditorPane;
}
/**
* Recording directory maximum size threshold spinner
* @return spinner
*/
private Spinner<Integer> getRecordingSpinner()
{
if(mRecordingSpinner == null)
{
mRecordingSpinner = new Spinner<>(100, Integer.MAX_VALUE, mDirectoryPreference.getDirectoryMaxUsageRecordings(), 100);
mRecordingSpinner.valueProperty().addListener((observable, oldValue, newValue) -> mDirectoryPreference
.setDirectoryMaxUsageRecordings(newValue));
}
return mRecordingSpinner;
}
/**
* Event log directory maximum size threshold spinner
* @return spinner
*/
private Spinner<Integer> getEventLogSpinner()
{
if(mEventLogSpinner == null)
{
mEventLogSpinner = new Spinner<>(100, Integer.MAX_VALUE, mDirectoryPreference.getDirectoryMaxUsageEventLogs(), 100);
mEventLogSpinner.setEditable(true);
mEventLogSpinner.valueProperty().addListener((observable, oldValue, newValue) -> mDirectoryPreference
.setDirectoryMaxUsageEventLogs(newValue));
}
return mEventLogSpinner;
}
private Label getApplicationRootLabel()
{
if(mApplicationRootLabel == null)