-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(csharp/ExcelAddIn): ExcelAddIn demo v7: Better GUI, better threa…
…ding, better sharing (#6031) More responses to demo user feedback. This version seems to be working pretty well.
- Loading branch information
Showing
35 changed files
with
1,369 additions
and
932 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 10 additions & 67 deletions
77
csharp/ExcelAddIn/factories/ConnectionManagerDialogFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,17 @@ | ||
using System.Collections.Concurrent; | ||
using Deephaven.ExcelAddIn.Managers; | ||
using Deephaven.ExcelAddIn.Viewmodels; | ||
using Deephaven.ExcelAddIn.ViewModels; | ||
using Deephaven.ExcelAddIn.Managers; | ||
using Deephaven.ExcelAddIn.Util; | ||
using Deephaven.ExcelAddIn.Views; | ||
|
||
namespace Deephaven.ExcelAddIn.Factories; | ||
|
||
internal static class ConnectionManagerDialogFactory { | ||
public static void CreateAndShow(StateManager sm) { | ||
var rowToManager = new ConcurrentDictionary<ConnectionManagerDialogRow, ConnectionManagerDialogRowManager>(); | ||
|
||
// The "new" button creates a "New/Edit Credentials" dialog | ||
void OnNewButtonClicked() { | ||
var cvm = CredentialsDialogViewModel.OfEmpty(); | ||
var dialog = CredentialsDialogFactory.Create(sm, cvm); | ||
dialog.Show(); | ||
} | ||
|
||
void OnDeleteButtonClicked(ConnectionManagerDialogRow[] rows) { | ||
foreach (var row in rows) { | ||
if (!rowToManager.TryGetValue(row, out var manager)) { | ||
continue; | ||
} | ||
manager.DoDelete(); | ||
} | ||
} | ||
|
||
void OnReconnectButtonClicked(ConnectionManagerDialogRow[] rows) { | ||
foreach (var row in rows) { | ||
if (!rowToManager.TryGetValue(row, out var manager)) { | ||
continue; | ||
} | ||
manager.DoReconnect(); | ||
} | ||
} | ||
|
||
void OnMakeDefaultButtonClicked(ConnectionManagerDialogRow[] rows) { | ||
// Make the last selected row the default | ||
if (rows.Length == 0) { | ||
return; | ||
} | ||
|
||
var row = rows[^1]; | ||
if (!rowToManager.TryGetValue(row, out var manager)) { | ||
return; | ||
} | ||
|
||
manager.DoSetAsDefault(); | ||
} | ||
|
||
void OnEditButtonClicked(ConnectionManagerDialogRow[] rows) { | ||
foreach (var row in rows) { | ||
if (!rowToManager.TryGetValue(row, out var manager)) { | ||
continue; | ||
} | ||
manager.DoEdit(); | ||
} | ||
} | ||
|
||
var cmDialog = new ConnectionManagerDialog(OnNewButtonClicked, OnDeleteButtonClicked, | ||
OnReconnectButtonClicked, OnMakeDefaultButtonClicked, OnEditButtonClicked); | ||
cmDialog.Show(); | ||
var dm = new ConnectionManagerDialogManager(cmDialog, rowToManager, sm); | ||
var disposer = sm.SubscribeToSessions(dm); | ||
|
||
cmDialog.Closed += (_, _) => { | ||
disposer.Dispose(); | ||
dm.Dispose(); | ||
}; | ||
public static void CreateAndShow(StateManager stateManager) { | ||
Utility.RunInBackground(() => { | ||
var cmDialog = new ConnectionManagerDialog(); | ||
var dm = ConnectionManagerDialogManager.Create(stateManager, cmDialog); | ||
cmDialog.Closed += (_, _) => dm.Dispose(); | ||
// Blocks forever (in this private thread) | ||
cmDialog.ShowDialog(); | ||
}); | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.