Ejemplo n.º 1
0
        public void LoadItems([NotNull] List <ItemVersionUri> items, [NotNull] LoadItemsOptions options)
        {
            Assert.ArgumentNotNull(items, nameof(items));
            Assert.ArgumentNotNull(options, nameof(options));

            contentEditor.LoadItems(items, options);
        }
Ejemplo n.º 2
0
        private void GoForward([NotNull] object sender, [NotNull] ExecutedRoutedEventArgs e)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(e, nameof(e));

            var list = Journal.GoForward();

            var options = new LoadItemsOptions(false);

            LoadItems(list, options);
        }
Ejemplo n.º 3
0
        public void LoadItems([NotNull] List <ItemVersionUri> itemUriList, [NotNull] LoadItemsOptions options)
        {
            Assert.ArgumentNotNull(itemUriList, nameof(itemUriList));
            Assert.ArgumentNotNull(options, nameof(options));

            if (LoadItemsOperation != null && LoadItemsOperation.ItemsToLoad > 0)
            {
                AppHost.MessageBox(Rocks.Resources.You_are_already_loading_items, Rocks.Resources.ContentEditorLoadItemsLoading_in_Progress, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            if (ContentModel.IsModified)
            {
                if (options.ForceReload)
                {
                    switch (AppHost.MessageBox("There are unsaved changes.\n\nDo you want to save?", "Information", MessageBoxButton.YesNoCancel, MessageBoxImage.Question))
                    {
                    case MessageBoxResult.Cancel:
                        return;

                    case MessageBoxResult.Yes:
                        Save();
                        break;

                    case MessageBoxResult.No:
                        break;
                    }
                }
                else
                {
                    options.NewTab      = true;
                    options.ForceReload = true;
                    AppHost.Windows.OpenContentEditor(itemUriList, options);
                    return;
                }
            }

            Pane.Caption = Rocks.Resources.Loading;
            ItemBreadcrumb.StartLoading();

            Editor.IsEnabled = false;
            try
            {
                ClearFieldControls(ContentModel);

                LoadItemsOperation = new LoadItemsOperation
                {
                    ItemsToLoad = itemUriList.Count,
                    Options     = options
                };

                var pipeline = LoadItemsPipeline.Run().WithParameters(itemUriList, LoadItemsOperation);

                ContentModel = pipeline.ContentModel;

                if (itemUriList.Count == 0)
                {
                    LoadItemsCompleted();
                    return;
                }

                try
                {
                    foreach (var uri in itemUriList)
                    {
                        if (uri.Site.DataService.GetItemFieldsAsync(uri, GetItemFieldsCallback))
                        {
                            continue;
                        }

                        AppHost.Output.Log("Failed to load item: " + uri.ItemId);
                        LoadItemsOperation.ItemsToLoad = 0;
                        return;
                    }
                }
                catch
                {
                    AppHost.Output.Log("Failed to load items");
                    LoadItemsOperation.ItemsToLoad = 0;
                    throw;
                }
            }
            finally
            {
                Editor.IsEnabled = true;
            }
        }