Esempio n. 1
0
        protected virtual void OnAddExecute(EditableJsonNode value)
        {
            JsonTreeEditor editor = this.GetEditor();

            if (editor != null)
            {
                editor.CreateEditableNode(value);
            }
        }
Esempio n. 2
0
        public void RemoveEditableNode(EditableJsonNode node)
        {
            if (this.Items.Contains(node))
            {
                this.Items.Remove(node);

                if (this.Items.Count == 0 && this.IsEditting)
                {
                    this.IsArray = false;
                }

                CollectionViewSource.GetDefaultView(this.Items).Refresh();
            }
        }
Esempio n. 3
0
        private void EnsureAddItem(EditableJsonNode item)
        {
            item.Parent = this;

            int idx = this.Items.Count;

            for (int i = 0; i < this.Items.Count; i++)
            {
                if (string.CompareOrdinal(this.Items[i].Key, item.Key) >= 0)
                {
                    idx = i;
                    break;
                }
            }

            this.Items.Insert(idx, item);
        }
Esempio n. 4
0
        private async void OnDeleteExecute(EditableJsonNode value)
        {
            JsonTreeEditor editor = this.GetEditor();

            if (editor == null)
            {
                throw new Exception();
            }

            if (value.IsEditting)
            {
                editor.DeleteEditableNode(value);
            }
            else
            {
                string path         = editor.GetDatastorePath(value);
                string relativePath = editor.GetRelativePath(path);

                // Json Root
                if (string.IsNullOrEmpty(relativePath))
                {
                    return;
                }

                if (MessageBox.Show(
                        $"중첩된 데이터를 포함하여 이 위치의 모든 데이터가 영구적으로 삭제됩니다.\r\n\r\n데이터 위치\r\n{editor.GetRelativePath(path)}",
                        "데이터 삭제",
                        MessageBoxButton.YesNo,
                        MessageBoxImage.Asterisk) == MessageBoxResult.No)
                {
                    return;
                }

                await editor.Datastore.DeleteAsync(path);
            }
        }