Пример #1
0
        private void RemoveHdfsServer(HdfsDrive drive)
        {
            try
            {
                if (MessageBox.Show(
                        String.Format(Resources.RemoveHdfsServerQuestion, drive.Label),
                        Resources.RemoveHdfsServerCaption,
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2) != DialogResult.Yes)
                    return;

                _drives.Remove(drive.Key);
                StoreHdfsDrives();
                leftDirectoryTree.Nodes.RemoveByKey(drive.Key);
                rightDirectoryTree.Nodes.RemoveByKey(drive.Key);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.ErrorCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
            }
        }
Пример #2
0
        private void EditHdfsServer(HdfsDrive drive)
        {
            var currentDriveKey = drive.Key;
            var driveForm = new HdfsDriveForm { Drive = drive };
            if (driveForm.ShowDialog() != DialogResult.OK) return;

            _drives.Remove(currentDriveKey);
            var newDrive = driveForm.Drive;
            if (!_drives.ContainsKey(newDrive.Key))
            {
                _drives.Add(newDrive.Key, newDrive);
                StoreHdfsDrives();
                var nodes = leftDirectoryTree.Nodes.Find(currentDriveKey, false);
                if (nodes.Length == 1)
                {
                    leftDirectoryTree.Nodes[nodes[0].Index].Name = newDrive.Key;
                    leftDirectoryTree.Nodes[nodes[0].Index].Text = newDrive.Label;
                    leftDirectoryTree.Nodes[nodes[0].Index].Nodes.Clear();
                    leftDirectoryTree.Nodes[nodes[0].Index].Nodes.Add(Resources.LoadingText);
                }
                nodes = rightDirectoryTree.Nodes.Find(currentDriveKey, false);
                if (nodes.Length == 1)
                {
                    rightDirectoryTree.Nodes[nodes[0].Index].Name = newDrive.Key;
                    rightDirectoryTree.Nodes[nodes[0].Index].Text = newDrive.Label;
                    rightDirectoryTree.Nodes[nodes[0].Index].Nodes.Clear();
                    rightDirectoryTree.Nodes[nodes[0].Index].Nodes.Add(Resources.LoadingText);
                }
            }
            else
            {
                MessageBox.Show(Resources.HdfsDriveExistsMessage, Resources.ErrorCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error,
                                MessageBoxDefaultButton.Button1);
            }
        }