mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-07-01 16:33:43 -04:00
[Core] Spit and polish on PluginList and tabs (#138)
Add checkboxes to the PluginList which allow you to enable/disable each plugin on-the-fly (it will no longer respond to events, but you can still configure it, etc.). These settings are preserved in a new Core setting. Also enabled full-row select for easier selection in the listview. Also increased the height of the PluginList slightly. (Personally, I'd like it even taller.) Also made slight sizing adjustments to the plugin tabs, which now show 3 letters when collapsed and has a bit of extra space so the longest one does not get cut-off when selected/bolded. Furthermore, the list of plugins is now sorted alphabetically. Finally, set the plugin listview Dock = Fill (vs. Anchored). This seems to have fixed the listview resize problem I was experiencing.
This commit is contained in:
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using Observatory.Framework.Files.Journal;
|
||||
using System.Timers;
|
||||
using Observatory.Utils;
|
||||
using Observatory.Framework.Files.ParameterTypes;
|
||||
|
||||
namespace Observatory.PluginManagement
|
||||
{
|
||||
@ -14,6 +15,7 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
private IEnumerable<IObservatoryWorker> observatoryWorkers;
|
||||
private IEnumerable<IObservatoryNotifier> observatoryNotifiers;
|
||||
private HashSet<IObservatoryPlugin> disabledPlugins;
|
||||
private List<(string error, string detail)> errorList;
|
||||
private System.Timers.Timer timer;
|
||||
|
||||
@ -21,6 +23,7 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
this.observatoryWorkers = observatoryWorkers;
|
||||
this.observatoryNotifiers = observatoryNotifiers;
|
||||
disabledPlugins = new();
|
||||
errorList = new();
|
||||
|
||||
InitializeTimer();
|
||||
@ -39,6 +42,7 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
foreach (var worker in observatoryWorkers)
|
||||
{
|
||||
if (disabledPlugins.Contains(worker)) continue;
|
||||
try
|
||||
{
|
||||
worker.JournalEvent((JournalBase)journalEventArgs.journalEvent);
|
||||
@ -59,6 +63,7 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
foreach (var worker in observatoryWorkers)
|
||||
{
|
||||
if (disabledPlugins.Contains(worker)) continue;
|
||||
try
|
||||
{
|
||||
worker.StatusChange((Status)journalEventArgs.journalEvent);
|
||||
@ -79,13 +84,14 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
foreach (var worker in observatoryWorkers)
|
||||
{
|
||||
if (disabledPlugins.Contains(worker)) continue;
|
||||
try
|
||||
{
|
||||
worker.LogMonitorStateChanged(e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RecordError(ex, worker.Name, "LogMonitorStateChanged event", ex.StackTrace);
|
||||
RecordError(ex, worker.Name, "LogMonitorStateChanged event", ex.StackTrace ?? "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -94,6 +100,7 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
foreach (var notifier in observatoryNotifiers)
|
||||
{
|
||||
if (disabledPlugins.Contains(notifier)) continue;
|
||||
try
|
||||
{
|
||||
notifier.OnNotificationEvent(notificationArgs);
|
||||
@ -114,10 +121,29 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
foreach (var plugin in observatoryNotifiers.Cast<IObservatoryPlugin>().Concat(observatoryWorkers))
|
||||
{
|
||||
plugin.HandlePluginMessage(messageArgs.SourceName, messageArgs.SourceVersion, messageArgs.Message);
|
||||
if (disabledPlugins.Contains(plugin)) continue;
|
||||
|
||||
try
|
||||
{
|
||||
plugin.HandlePluginMessage(messageArgs.SourceName, messageArgs.SourceVersion, messageArgs.Message);
|
||||
}
|
||||
catch (PluginException ex)
|
||||
{
|
||||
RecordError(ex);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
RecordError(ex, plugin.Name, "OnPluginMessageEvent event", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPluginEnabled(IObservatoryPlugin plugin, bool enabled)
|
||||
{
|
||||
if (enabled) disabledPlugins.Remove(plugin);
|
||||
else disabledPlugins.Add(plugin);
|
||||
}
|
||||
|
||||
private void ResetTimer()
|
||||
{
|
||||
timer.Stop();
|
||||
@ -136,7 +162,7 @@ namespace Observatory.PluginManagement
|
||||
|
||||
private void RecordError(PluginException ex)
|
||||
{
|
||||
errorList.Add(($"Error in {ex.PluginName}: {ex.Message}", ex.StackTrace));
|
||||
errorList.Add(($"Error in {ex.PluginName}: {ex.Message}", ex.StackTrace ?? ""));
|
||||
}
|
||||
|
||||
private void RecordError(Exception ex, string plugin, string eventType, string eventDetail)
|
||||
|
@ -36,12 +36,13 @@ namespace Observatory.PluginManagement
|
||||
public readonly List<(IObservatoryWorker plugin, PluginStatus signed)> workerPlugins;
|
||||
public readonly List<(IObservatoryNotifier plugin, PluginStatus signed)> notifyPlugins;
|
||||
private readonly PluginCore core;
|
||||
private readonly PluginEventHandler pluginHandler;
|
||||
|
||||
private PluginManager()
|
||||
{
|
||||
errorList = LoadPlugins(out workerPlugins, out notifyPlugins);
|
||||
|
||||
var pluginHandler = new PluginEventHandler(workerPlugins.Select(p => p.plugin), notifyPlugins.Select(p => p.plugin));
|
||||
pluginHandler = new PluginEventHandler(workerPlugins.Select(p => p.plugin), notifyPlugins.Select(p => p.plugin));
|
||||
var logMonitor = LogMonitor.GetInstance;
|
||||
pluginPanels = new();
|
||||
pluginTables = new();
|
||||
@ -196,6 +197,11 @@ namespace Observatory.PluginManagement
|
||||
SettingsManager.Save();
|
||||
}
|
||||
|
||||
public void SetPluginEnabled(IObservatoryPlugin plugin, bool enabled)
|
||||
{
|
||||
pluginHandler.SetPluginEnabled(plugin, enabled);
|
||||
}
|
||||
|
||||
private static List<(string, string?)> LoadPlugins(out List<(IObservatoryWorker plugin, PluginStatus signed)> observatoryWorkers, out List<(IObservatoryNotifier plugin, PluginStatus signed)> observatoryNotifiers)
|
||||
{
|
||||
observatoryWorkers = new();
|
||||
|
Reference in New Issue
Block a user