private void ValidateActiveEntity(BaseEntity expectedEntity) { if (expectedEntity == null) { Assert.IsNull(WorkspaceSessionPersistanceManager.GetActiveEntity(), "There shouldn't be any active entity"); return; } var activeEntity = WorkspaceSessionPersistanceManager.GetActiveEntity(); Assert.AreEqual(expectedEntity.Id, activeEntity.Id, "Mismatched entity ids"); Assert.AreEqual(VisualStudio.Common.Utility.GetConcreteEntityType(expectedEntity), VisualStudio.Common.Utility.GetConcreteEntityType(activeEntity), "Mismatched entity types"); Assert.IsTrue(WorkspaceSessionPersistanceManager.IsActiveEntity(expectedEntity), "Entity isn't the active entity"); }
/// <summary> /// Update active item button in toolbar with the current active item's information /// </summary> public void UpdateActiveItemInToolbar() { try { var activeEntity = WorkspaceSessionPersistanceManager.GetActiveEntity(); if (activeEntity != null) { _activeItemMenuCommand.Text = EntityTypeRegistry.GetEntityTypeInformation(activeEntity).ShortLabel + " " + activeEntity.Id; _activeItemMenuCommand.Enabled = true; _copyCommitMessageCommand.Enabled = true; _stopWorkCommand.Enabled = true; } else { DisableActiveItemToolbar(); } } catch (Exception ex) { MessageBox.Show("Unable to update active item in Octane toolbar.\n\n" + "Failed with message: " + ex.Message, ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void OpenActiveItemInDetailsWindowCallback(object caller, EventArgs args) { try { var command = caller as OleMenuCommand; if (command == null) { return; } var activeEntity = WorkspaceSessionPersistanceManager.GetActiveEntity(); if (activeEntity == null) { return; } PluginWindowManager.ShowDetailsWindow(MainWindow.PluginPackage, activeEntity); } catch (Exception ex) { MessageBox.Show("Unable to open details window for active item.\n\n" + "Failed with message: " + ex.Message, ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Error); } }