public static ConceptNodeViewModel Indent(this ConceptNodeViewModel @this)
        {
            ICodeLineViewModel codeLine = @this.BottomCodeLine();

            codeLine.Nodes.Add(new IndentNodeViewModel(@this));
            return(@this);
        }
        public static ConceptNodeViewModel Literal(this ConceptNodeViewModel @this, string literal)
        {
            if (string.IsNullOrWhiteSpace(literal))
            {
                throw new ArgumentNullException(nameof(literal));
            }

            ISyntaxNodeViewModel syntaxNode = @this.LastSyntaxNode();

            if (syntaxNode is PropertyViewModel property)
            {
                property.Nodes.Add(new LiteralNodeViewModel(property)
                {
                    Literal         = literal,
                    PropertyBinding = property.PropertyBinding
                });
            }
            else
            {
                ICodeLineViewModel codeLine = @this.BottomCodeLine();
                codeLine.Nodes.Add(new LiteralNodeViewModel(@this)
                {
                    Literal = literal
                });
            }
            return(@this);

            //ICodeLineViewModel codeLine = @this.BottomCodeLine();
            //codeLine.Nodes.Add(new LiteralNodeViewModel(@this) { Literal = literal });
        }
        public static ConceptNodeViewModel Identifier(this ConceptNodeViewModel @this)
        {
            ICodeLineViewModel codeLine = @this.BottomCodeLine();

            codeLine.Nodes.Add(new IdentifierNodeViewModel(@this, @this.SyntaxNode));
            return(@this);
        }
Ejemplo n.º 4
0
 public PropertyViewModel(ConceptNodeViewModel owner) : base(owner, owner.SyntaxNode)
 {
     if (owner == null)
     {
         throw new ArgumentNullException(nameof(owner));
     }
 }
Ejemplo n.º 5
0
        protected override void OnMouseDown(object parameter)
        {
            if (!(parameter is MouseButtonEventArgs args))
            {
                return;
            }
            if (args.ChangedButton == MouseButton.Right)
            {
                return;
            }
            args.Handled = true;

            // TODO: move this code to SyntaxTreeManager
            PropertyInfo         property   = Owner.SyntaxNode.GetPropertyInfo(PropertyBinding);
            Type                 optionType = SyntaxTreeManager.GetPropertyType(property);
            ISyntaxNode          concept    = SyntaxTreeManager.CreateConcept(optionType, Owner.SyntaxNode, PropertyBinding);
            ConceptNodeViewModel node       = SyntaxTreeController.Current.CreateSyntaxNode(Owner, concept);

            node.PropertyBinding = PropertyBinding;

            NodePosition position = Owner.GetPosition(this);

            Owner.Lines[position.Line].Nodes.RemoveAt(position.Position + 1); // remove concept view model from layout
            Owner.Lines[position.Line].Nodes.RemoveAt(position.Position);     // remove this concept option command
            Owner.Lines[position.Line].Nodes.Add(node);                       // add newly created concept node
        }
Ejemplo n.º 6
0
 public ConceptOptionViewModel(ConceptNodeViewModel owner) : base(owner)
 {
     if (owner == null)
     {
         throw new ArgumentNullException(nameof(owner));
     }
 }
        public static ConceptNodeViewModel Keyword(this ConceptNodeViewModel @this, string keyword)
        {
            if (string.IsNullOrWhiteSpace(keyword))
            {
                throw new ArgumentNullException(nameof(keyword));
            }

            ISyntaxNodeViewModel syntaxNode = @this.LastSyntaxNode();

            if (syntaxNode is PropertyViewModel property)
            {
                property.Nodes.Add(new KeywordNodeViewModel(property)
                {
                    Keyword         = keyword,
                    PropertyBinding = property.PropertyBinding
                });
            }
            else
            {
                ICodeLineViewModel codeLine = @this.BottomCodeLine();
                codeLine.Nodes.Add(new KeywordNodeViewModel(@this)
                {
                    Keyword = keyword
                });
            }
            return(@this);
            //ICodeLineViewModel codeLine = @this.BottomCodeLine();
            //codeLine.Nodes.Add(new KeywordNodeViewModel(@this) { Keyword = keyword });
        }
 public RemoveConceptViewModel(ConceptNodeViewModel owner) : base(owner)
 {
     if (owner == null)
     {
         throw new ArgumentNullException(nameof(owner));
     }
     IntializeViewModel();
 }
Ejemplo n.º 9
0
        private void CreateRepetableOption(Type optionType, ISyntaxNode parent, string propertyName)
        {
            // TODO: move this code to SyntaxTreeManager
            ISyntaxNode          model = SyntaxTreeManager.CreateRepeatableConcept(optionType, parent, propertyName);
            ConceptNodeViewModel node  = SyntaxTreeController.Current.CreateSyntaxNode(Owner, model);

            Owner.Add(node);
        }
        public static ConceptNodeViewModel Repeatable(this ConceptNodeViewModel @this)
        {
            ICodeLineViewModel codeLine = @this
                                          .NewLine()
                                          .BottomCodeLine();

            codeLine.Nodes.Add(new RepeatableViewModel(@this));
            return(@this);
        }
        private static void SetSyntaxNodesVisibility(ConceptNodeViewModel @this, string propertyName, bool isVisible)
        {
            if (string.IsNullOrWhiteSpace(propertyName))
            {
                return;
            }

            foreach (ISyntaxNodeViewModel node in @this.GetNodesByPropertyName(propertyName))
            {
                node.IsVisible = isVisible;
            }
        }
Ejemplo n.º 12
0
        protected virtual void OnMouseLeave(object parameter)
        {
            IsMouseOver = false;
            ConceptNodeViewModel concept = this.Ancestor <ConceptNodeViewModel>() as ConceptNodeViewModel;

            if (concept != null)
            {
                if (concept.Owner is RepeatableViewModel)
                {
                    concept.HideCommands();
                }
            }
        }
        public static ConceptNodeViewModel Property(this ConceptNodeViewModel @this, string propertyName)
        {
            if (string.IsNullOrWhiteSpace(propertyName))
            {
                throw new ArgumentNullException(nameof(propertyName));
            }

            ICodeLineViewModel codeLine = @this.BottomCodeLine();

            codeLine.Nodes.Add(new PropertyViewModel(@this)
            {
                PropertyBinding = propertyName
            });
            return(@this);
        }
        public static ConceptNodeViewModel Delimiter(this ConceptNodeViewModel @this, string delimiterLiteral)
        {
            ISyntaxNodeViewModel syntaxNode = @this.LastSyntaxNode();

            if (syntaxNode == null)
            {
                throw new ArgumentNullException(nameof(syntaxNode));
            }
            if (!(syntaxNode is RepeatableViewModel repeatable))
            {
                return(@this);
            }

            repeatable.Delimiter = delimiterLiteral;
            return(@this);
        }
        public static ConceptNodeViewModel Bind(this ConceptNodeViewModel @this, string propertyName)
        {
            if (string.IsNullOrWhiteSpace(propertyName))
            {
                throw new ArgumentNullException(nameof(propertyName));
            }

            ISyntaxNodeViewModel syntaxNode = @this.LastSyntaxNode();

            if (syntaxNode == null)
            {
                throw new ArgumentNullException(nameof(syntaxNode));
            }

            syntaxNode.PropertyBinding = propertyName;
            return(@this);
        }
        public static ConceptNodeViewModel Decorate(this ConceptNodeViewModel @this, string openingLiteral, string closingLiteral)
        {
            ISyntaxNodeViewModel syntaxNode = @this.LastSyntaxNode();

            if (syntaxNode == null)
            {
                throw new ArgumentNullException(nameof(syntaxNode));
            }
            if (!(syntaxNode is RepeatableViewModel repeatable))
            {
                return(@this);
            }

            repeatable.OpeningLiteral = openingLiteral;
            repeatable.ClosingLiteral = closingLiteral;
            return(@this);
        }
Ejemplo n.º 17
0
        protected virtual void OnMouseDown(object parameter)
        {
            if (!(parameter is MouseButtonEventArgs args))
            {
                return;
            }
            if (args.ChangedButton == MouseButton.Right)
            {
                return;
            }

            ConceptNodeViewModel concept = this.Ancestor <ConceptNodeViewModel>() as ConceptNodeViewModel;

            if (concept != null)
            {
                concept.ProcessOptionSelection(PropertyBinding);
            }
        }
Ejemplo n.º 18
0
        protected virtual void OnMouseEnter(object parameter)
        {
            IsMouseOver = true;
            ConceptNodeViewModel concept = this.Ancestor <ConceptNodeViewModel>() as ConceptNodeViewModel;

            if (concept != null)
            {
                // show options only if first line is entered ...
                if (concept.Lines.Count > 0)
                {
                    if (concept.Lines[0].Nodes.Count > 0)
                    {
                        for (int i = 0; i < concept.Lines[0].Nodes.Count; i++)
                        {
                            var node = concept.Lines[0].Nodes[i];
                            if (node is IndentNodeViewModel)
                            {
                                continue;
                            }
                            if (node == this)
                            {
                                concept.ShowOptions();
                                if (concept.Owner is RepeatableViewModel)
                                {
                                    concept.ShowCommands();
                                }
                                else if (concept.Owner is ConceptNodeViewModel)
                                {
                                    PropertyInfo property = concept.Owner.SyntaxNode.GetPropertyInfo(concept.PropertyBinding);
                                    if (property.IsOptional())
                                    {
                                        concept.ShowCommands();
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
        public static List <ISyntaxNodeViewModel> GetNodesByPropertyName(this ConceptNodeViewModel @this, string propertyName)
        {
            if (string.IsNullOrWhiteSpace(propertyName))
            {
                throw new ArgumentNullException(nameof(propertyName));
            }

            List <ISyntaxNodeViewModel> nodes = new List <ISyntaxNodeViewModel>();

            foreach (ICodeLineViewModel line in @this.Lines)
            {
                foreach (ISyntaxNodeViewModel node in line.Nodes)
                {
                    if (node.PropertyBinding == propertyName)
                    {
                        nodes.Add(node);
                    }
                }
            }
            return(nodes);
        }
        public static ConceptNodeViewModel Selector(this ConceptNodeViewModel @this)
        {
            ISyntaxNodeViewModel syntaxNode = @this.LastSyntaxNode();

            if (syntaxNode is PropertyViewModel property)
            {
                property.Nodes.Add(new SelectorViewModel(property)
                {
                    PropertyBinding = property.PropertyBinding
                });
            }
            else
            {
                ICodeLineViewModel codeLine = @this.BottomCodeLine();
                codeLine.Nodes.Add(new SelectorViewModel(@this));
            }
            return(@this);

            //ICodeLineViewModel codeLine = @this.BottomCodeLine();
            //codeLine.Nodes.Add(new SelectorViewModel(@this));
        }
        public ConceptNodeViewModel CreateSyntaxNode(ISyntaxNodeViewModel parentNode, ISyntaxNode model)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            IConceptLayout layout = GetLayout(model);

            if (layout == null)
            {
                return(null);
            }

            ConceptNodeViewModel node = layout.Layout(model) as ConceptNodeViewModel;

            node.Owner = parentNode;
            InitializeConceptViewModel(node);

            return(node);
        }
        private void InitializeRepeatableViewModel(ISyntaxNodeViewModel repeatableNode)
        {
            ISyntaxNodeViewModel parentNode = repeatableNode.Owner;
            ISyntaxNode          concept    = parentNode.SyntaxNode;
            string propertyBinding          = repeatableNode.PropertyBinding;

            IList        conceptChildren;
            PropertyInfo property = concept.GetPropertyInfo(propertyBinding);

            if (property.IsOptional())
            {
                IOptional optional = (IOptional)property.GetValue(concept);
                if (optional == null || !optional.HasValue)
                {
                    return;
                }
                conceptChildren = (IList)optional.Value;
            }
            else
            {
                conceptChildren = (IList)property.GetValue(concept);
            }
            if (conceptChildren == null || conceptChildren.Count == 0)
            {
                return;
            }
            foreach (var child in conceptChildren)
            {
                if (!(child is SyntaxNode))
                {
                    continue;
                }
                ConceptNodeViewModel conceptViewModel = CreateSyntaxNode(repeatableNode, (ISyntaxNode)child);
                if (conceptViewModel == null)
                {
                    continue;
                }
                repeatableNode.Add(conceptViewModel);
            }
        }
 public static ConceptNodeViewModel NewLine(this ConceptNodeViewModel @this)
 {
     @this.Lines.Add(new CodeLineViewModel(@this));
     return(@this);
 }
 public static void HideSyntaxNodes(this ConceptNodeViewModel @this, string propertyName)
 {
     SetSyntaxNodesVisibility(@this, propertyName, false);
 }