Пример #1
0
        protected override void Process(GetChildrenPipeline pipeline)
        {
            Debug.ArgumentNotNull(pipeline, nameof(pipeline));

            if (pipeline.BaseFolder != null || pipeline.ParentItem != null)
            {
                return;
            }

            var folder = ConnectionManager.GetConnectionFolder();

            var item = new ConnectionFolderTreeViewItem(folder)
            {
                Margin = new Thickness(0, 16, 0, 0)
            };

            if (AppHost.Files.GetFiles(folder).Length > 0 || AppHost.Files.GetDirectories(folder).Length > 0)
            {
                item.MakeExpandable();
            }

            pipeline.Items.Add(item);

            if (AppHost.Settings.Get(ConnectionFolderTreeViewItem.RegistryPath, ConnectionFolderTreeViewItem.ConnectionsRelativeFolder, null) == null)
            {
                AppHost.Settings.SetBool(ConnectionFolderTreeViewItem.RegistryPath, ConnectionFolderTreeViewItem.ConnectionsRelativeFolder, true);
            }
        }
Пример #2
0
        private static void CreateSiteTreeViewItem([NotNull] Site site, [CanBeNull] ConnectionFolderTreeViewItem parent)
        {
            Debug.ArgumentNotNull(site, nameof(site));

            var activeContentTree = ActiveContext.ActiveContentTree;

            if (activeContentTree == null)
            {
                var s = site;

                ActiveContext.ActiveContentTreeChanged += delegate
                {
                    if (s != null)
                    {
                        CreateSiteTreeViewItem(s, parent);
                    }

                    s = null;
                };

                return;
            }

            var item = site.GetTreeViewItem();

            if (item == null)
            {
                return;
            }

            item.Text = site.Name;
            item.Items.Add(DummyTreeViewItem.Instance);

            if (parent != null)
            {
                parent.Items.Add(item);
                return;
            }

            var treeView = activeContentTree.ItemTreeView.TreeView;

            foreach (var i in treeView.Items)
            {
                var connections = i as ConnectionFolderTreeViewItem;

                if (connections != null)
                {
                    connections.Add(item);
                    return;
                }
            }

            treeView.Items.Add(item);
        }
Пример #3
0
        private void LoadSites()
        {
            TreeView.Items.Clear();

            var folder = ConnectionManager.GetConnectionFolder();

            var item = new ConnectionFolderTreeViewItem(folder);

            item.MakeExpandable();

            TreeView.Items.Add(item);

            item.ExpandAndWait();

            LocateSite();
        }
        protected override void Process(GetChildrenPipeline pipeline)
        {
            Debug.ArgumentNotNull(pipeline, nameof(pipeline));

            if (pipeline.BaseFolder == null)
            {
                return;
            }

            if (!Directory.Exists(pipeline.BaseFolder))
            {
                return;
            }

            SiteManager.LoadSites();
            var subfolders = AppHost.Files.GetDirectories(pipeline.BaseFolder).ToList();

            var localConnectionFolder = ConnectionManager.GetLocalConnectionFolder();

            if (subfolders.Any(f => string.Compare(f, localConnectionFolder, StringComparison.InvariantCultureIgnoreCase) == 0))
            {
                if (AppHost.Files.GetFiles(localConnectionFolder).Length != 0 || AppHost.Files.GetDirectories(localConnectionFolder).Length != 0 || WebAdministration.CanAdminister)
                {
                    var item = new LocalConnectionFolderTreeViewItem(localConnectionFolder);

                    item.MakeExpandable();

                    pipeline.Items.Add(item);
                }

                subfolders.Remove(localConnectionFolder);
            }

            foreach (var folder in subfolders.OrderBy(f => f))
            {
                var item = new ConnectionFolderTreeViewItem(folder);

                if (AppHost.Files.GetFiles(folder).Length > 0 || AppHost.Files.GetDirectories(folder).Length > 0)
                {
                    item.MakeExpandable();
                }

                pipeline.Items.Add(item);
            }
        }
Пример #5
0
        private void LoadDatabases()
        {
            TreeView.Items.Clear();

            var folder = ConnectionManager.GetConnectionFolder();

            var item = new ConnectionFolderTreeViewItem(folder);

            item.MakeExpandable();

            TreeView.Items.Add(item);

            item.ExpandAndWait();

            if (SelectedDatabaseUri == DatabaseUri.Empty)
            {
                return;
            }

            LocateDatabase();
        }
Пример #6
0
        private void LoadTreeView([NotNull] object sender, [NotNull] RoutedEventArgs routedEventArgs)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(routedEventArgs, nameof(routedEventArgs));

            TreeView.Loaded -= LoadTreeView;

            TreeView.Items.Clear();

            var folder = ConnectionManager.GetConnectionFolder();

            var item = new ConnectionFolderTreeViewItem(folder);

            TreeView.Items.Add(item);
            item.MakeExpandable();
            item.IsExpanded = true;

            LocateSite();

            _isLoaded = true;
        }
Пример #7
0
        public override void Execute(object parameter)
        {
            var context = parameter as ContentTreeContext;

            if (context == null)
            {
                return;
            }

            var folderName = AppHost.Prompt("Enter the name of the folder:", "Connections", string.Empty);

            if (string.IsNullOrEmpty(folderName))
            {
                return;
            }

            if (!context.SelectedItems.Any())
            {
                folderName = Path.Combine(ConnectionManager.GetConnectionFolder(), folderName);
                Directory.CreateDirectory(folderName);

                var item = new ConnectionFolderTreeViewItem(folderName);
                context.ContentTree.TreeView.Items.Add(item);

                return;
            }

            var parentItem = context.SelectedItems.FirstOrDefault() as ConnectionFolderTreeViewItem;

            if (parentItem == null)
            {
                return;
            }

            folderName = Path.Combine(parentItem.Folder, folderName);
            Directory.CreateDirectory(folderName);
            parentItem.Refresh();
        }
Пример #8
0
        private void LoadTreeView([NotNull] object sender, [NotNull] RoutedEventArgs routedEventArgs)
        {
            Debug.ArgumentNotNull(sender, nameof(sender));
            Debug.ArgumentNotNull(routedEventArgs, nameof(routedEventArgs));

            TreeView.Loaded -= LoadTreeView;

            TreeView.Items.Clear();

            var folder = ConnectionManager.GetConnectionFolder();

            var item = new ConnectionFolderTreeViewItem(folder);

            TreeView.Items.Add(item);
            item.MakeExpandable();
            item.IsExpanded = true;

            _isLoaded = true;

            if (DatabaseUri == DatabaseUri.Empty)
            {
                return;
            }

            var itemUri = new ItemUri(DatabaseUri, ItemId.Empty);
            var databaseTreeViewItem = TreeView.FindDatabaseTreeViewItem(itemUri);

            if (databaseTreeViewItem == null)
            {
                return;
            }

            databaseTreeViewItem.BringIntoView();
            databaseTreeViewItem.IsSelected     = true;
            databaseTreeViewItem.IsItemSelected = true;
            Keyboard.Focus(databaseTreeViewItem);
        }
Пример #9
0
        public static Site NewConnection([Localizable(false), NotNull] string hostName, [NotNull] string userName, [CanBeNull] ConnectionFolderTreeViewItem parent)
        {
            Assert.ArgumentNotNull(hostName, nameof(hostName));
            Assert.ArgumentNotNull(userName, nameof(userName));

            var connection = new Connection
            {
                UserName = userName,
                Password = @"b",
                HostName = hostName,
            };

            var site = new Site(connection);

            var dialog = new SiteEditor();

            dialog.Load(site);
            if (AppHost.Shell.ShowDialog(dialog) != true)
            {
                return(null);
            }

            if (FindSite(site.HostName, site.UserName) == null)
            {
                if (parent != null)
                {
                    connection.FileName = ConnectionManager.GetFileName(connection, parent.Folder);
                }

                Add(site);

                ConnectionManager.Add(site.Connection);
                ConnectionManager.Save();

                CreateSiteTreeViewItem(site, parent);

                Notifications.RaiseSiteAdded(site, site);
            }

            var editor = dialog.DataServiceEditor as WebServiceSiteEditor;

            if (editor != null)
            {
                if (editor.AutomaticUpdate.IsChecked == true)
                {
                    UpdateServerComponentsDialog.AutomaticUpdate(site.DataService, site.Name, site.WebRootPath, site);
                }
            }

            return(site);
        }
Пример #10
0
 public static Site NewConnection([CanBeNull] ConnectionFolderTreeViewItem parent)
 {
     return(NewConnection("localhost", @"sitecore\admin", parent));
 }