Beispiel #1
0
        protected override void SaveViewSpecList(ViewGroupId viewGroup, ViewSpecList viewSpecList)
        {
            Settings.Default.PersistedViews.SetViewSpecList(viewGroup, viewSpecList);
            if (Equals(viewGroup, PersistedViews.MainGroup.Id))
            {
                ChangeDocumentViewSpecList(docViewSpecList =>
                {
                    var newViews = new Dictionary <string, ViewSpec>();
                    foreach (var viewSpec in viewSpecList.ViewSpecs)
                    {
                        newViews[viewSpec.Name] = viewSpec;
                    }
                    var newDocViews = new List <ViewSpec>();
                    var newLayouts  = new List <ViewLayoutList>();
                    foreach (var oldDocView in docViewSpecList.ViewSpecs)
                    {
                        ViewSpec newDocView;
                        if (newViews.TryGetValue(oldDocView.Name, out newDocView))
                        {
                            newDocViews.Add(newDocView);
                            ViewLayoutList viewLayoutList = viewSpecList.GetViewLayouts(oldDocView.Name);
                            if (!viewLayoutList.IsEmpty)
                            {
                                newLayouts.Add(viewLayoutList);
                            }
                        }
                    }
                    return(new ViewSpecList(newDocViews, newLayouts));
                });

                var skylineWindow = SkylineDataSchema.SkylineWindow;
                if (skylineWindow != null)
                {
                    skylineWindow.ModifyDocument(Resources.SkylineViewContext_SaveViewSpecList_Change_Document_Reports, doc =>
                    {
                        var oldViewNames = new HashSet <string>(
                            doc.Settings.DataSettings.ViewSpecList.ViewSpecs.Select(spec => spec.Name));
                        var newViewSpecList = viewSpecList.Filter(spec => oldViewNames.Contains(spec.Name));
                        if (Equals(newViewSpecList, doc.Settings.DataSettings.ViewSpecList))
                        {
                            return(doc);
                        }
                        return(doc.ChangeSettings(doc.Settings.ChangeDataSettings(
                                                      doc.Settings.DataSettings.ChangeViewSpecList(newViewSpecList))));
                    }, AuditLogEntry.SettingsLogFunction);
                }
            }
        }
Beispiel #2
0
        private void AddDefaults()
        {
            if (RevisionIndex >= RevisionIndexCurrent)
            {
                return;
            }
            IList <KeyValuePair <ViewGroupId, ViewSpec> > previousDefaults = GetDefaults(RevisionIndex).ToArray();
            IList <KeyValuePair <ViewGroupId, ViewSpec> > currentDefaults  = GetDefaults(RevisionIndexCurrent).ToArray();

            foreach (var keyValuePair in currentDefaults)
            {
                if (previousDefaults.Contains(keyValuePair))
                {
                    continue;
                }
                var          viewGroup    = keyValuePair.Key;
                var          viewSpec     = keyValuePair.Value;
                ViewSpecList viewSpecList = GetViewSpecList(viewGroup);
                var          currentView  = viewSpecList.ViewSpecs.FirstOrDefault(view => view.Name == viewSpec.Name);
                if (currentView == null || previousDefaults.Contains(new KeyValuePair <ViewGroupId, ViewSpec>(viewGroup, currentView)))
                {
                    viewSpecList = viewSpecList.ReplaceView(viewSpec.Name, new ViewSpecLayout(viewSpec, viewSpecList.GetViewLayouts(viewSpec.Name)));
                    _viewSpecLists[viewGroup.Name] = viewSpecList;
                }
            }
            RevisionIndex = RevisionIndexCurrent;
        }