Esempio n. 1
0
        /// <summary>
        /// The event-handler that is invoked by the subscription that listens for updates
        /// on the <see cref="Session"/> that is being represented by the view-model
        /// </summary>
        /// <param name="sessionChange">
        /// The payload of the event that is being handled
        /// </param>
        private void SessionChangeEventHandler(SessionEvent sessionChange)
        {
            if (this.FluentRibbonManager == null)
            {
                return;
            }

            if (!this.FluentRibbonManager.IsActive)
            {
                return;
            }

            if (sessionChange.Status == SessionStatus.Open)
            {
                var session       = sessionChange.Session;
                var siteDirectory = session.RetrieveSiteDirectory();

                this.domainOfExpertiseBrowserViewModel = new DomainOfExpertiseBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService);
                this.modelBrowserViewModel             = new ModelBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService);
                this.naturalLanguageBrowserViewModel   = new NaturalLanguageBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService);
                this.organizationBrowserViewModel      = new OrganizationBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService);
                this.personBrowserViewModel            = new PersonBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService);
                this.roleBrowserViewModel    = new RoleBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService);
                this.siteRdlBrowserViewModel = new SiteRdlBrowserViewModel(session, siteDirectory, this.ThingDialogNavigationService, this.PanelNavigationService, this.DialogNavigationService, this.PluginSettingsService);

                this.Session = session;
            }

            if (sessionChange.Status == SessionStatus.Closed)
            {
                this.CloseAll();
                this.Session = null;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Close all the panels and dispose of them
        /// </summary>
        private void CloseAll()
        {
            this.PanelNavigationService.Close(this.domainOfExpertiseBrowserViewModel, false);
            this.domainOfExpertiseBrowserViewModel = null;

            this.PanelNavigationService.Close(this.modelBrowserViewModel, false);
            this.modelBrowserViewModel = null;

            this.PanelNavigationService.Close(this.naturalLanguageBrowserViewModel, false);
            this.naturalLanguageBrowserViewModel = null;

            this.PanelNavigationService.Close(this.organizationBrowserViewModel, false);
            this.organizationBrowserViewModel = null;

            this.PanelNavigationService.Close(this.personBrowserViewModel, false);
            this.personBrowserViewModel = null;

            this.PanelNavigationService.Close(this.roleBrowserViewModel, false);
            this.roleBrowserViewModel = null;

            this.PanelNavigationService.Close(this.siteRdlBrowserViewModel, false);
            this.siteRdlBrowserViewModel = null;
        }
Esempio n. 3
0
        public void VerifyThatPropertiesAreSet()
        {
            var viewmodel = new NaturalLanguageBrowserViewModel(this.session.Object, this.siteDir, null, null, null, null);

            Assert.AreEqual(1, viewmodel.NaturalLanguageRowViewModels.Count);
            Assert.IsTrue(viewmodel.Caption.Contains(viewmodel.Thing.Name));
            Assert.IsTrue(viewmodel.ToolTip.Contains(viewmodel.Thing.IDalUri.ToString()));

            this.siteDir.Name = "hoho";
            // workaround to modify a read-only field
            var type = this.siteDir.GetType();

            type.GetProperty("RevisionNumber").SetValue(this.siteDir, 50);

            var language = new NaturalLanguage(Guid.NewGuid(), this.assembler.Cache, this.uri)
            {
                Name         = "test",
                LanguageCode = "te2",
                NativeName   = "test"
            };

            this.siteDir.NaturalLanguage.Add(language);
            this.revField.SetValue(this.siteDir, 10);
            CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated);

            Assert.IsTrue(viewmodel.Caption.Contains(viewmodel.Thing.Name));

            // Verify that the add doesnt do anything as there is already a language with the same languagecode
            Assert.AreEqual(2, viewmodel.NaturalLanguageRowViewModels.Count);


            this.siteDir.NaturalLanguage.Remove(language);
            this.revField.SetValue(this.siteDir, 20);
            CDPMessageBus.Current.SendObjectChangeEvent(this.siteDir, EventKind.Updated);
            Assert.AreEqual(1, viewmodel.NaturalLanguageRowViewModels.Count);
        }