private void OnExpressionSelected(HermesViewModel selectedExpression) { PropertyExpression model = (PropertyExpression)this.Model; if (selectedExpression == null) { model.Expression = null; this.Expression = null; this.ExpressionView = null; return; } model.Expression = selectedExpression.Model; this.Expression = selectedExpression; //this.Expression.Parent = this; if (selectedExpression is PropertyReferenceViewModel) { //model.Expression.Consumer = model; if (string.IsNullOrEmpty(this.Alias)) { this.Alias = ((PropertyReferenceViewModel)this.Expression).Name; // this sets model's property Alias as well } this.ExpressionView = new PropertyReferenceView((PropertyReferenceViewModel)this.Expression); } else if (selectedExpression is ParameterReferenceViewModel) { this.Alias = ((ParameterReferenceViewModel)this.Expression).Name; // this sets model's property Alias as well this.ExpressionView = new ParameterReferenceView((ParameterReferenceViewModel)this.Expression); } }
public ComparisonOperatorViewModel(HermesViewModel parent, ComparisonOperator model) : base(parent, model) { this.InitializeViewModel(model); this.RemoveComparisonOperatorCommand = new DelegateCommand(this.RemoveComparisonOperator); this.OpenPropertySelectionDialogCommand = new DelegateCommand <string>(this.OpenPropertySelectionDialog); }
protected override object GetDialogResult() { if (this.SelectedNode != null && (this.SelectedNode is TableExpressionViewModel || this.SelectedNode is QueryExpressionViewModel)) { return(null); } if (this.SelectedNode is ParameterExpressionViewModel) { return(((ParameterExpressionViewModel)this.SelectedNode).GetParameterReferenceViewModel(this.SelectedNode.Parent)); } HermesViewModel parentVM = this.Caller as ComparisonOperatorViewModel; if (parentVM == null) { parentVM = this.Caller as PropertyExpressionViewModel; } PropertyReferenceViewModel selectedVM = this.SelectedNode as PropertyReferenceViewModel; PropertyReference source = selectedVM.Model as PropertyReference; if (parentVM != null && selectedVM != null && source != null) { PropertyReference model = new PropertyReference(parentVM.Model, source.Table, source.Property); return(new PropertyReferenceViewModel(parentVM, selectedVM.Table, model)); } else { return(null); } }
private void OnRightExpressionSelected(HermesViewModel selectedExpression) { ComparisonOperator model = (ComparisonOperator)this.Model; if (selectedExpression == null) { model.RightExpression = null; this.RightExpression = null; this.RightExpressionView = null; return; } model.RightExpression = selectedExpression.Model; this.RightExpression = selectedExpression; //this.RightExpression.Parent = this; if (selectedExpression is PropertyReferenceViewModel) { //model.RightExpression.Consumer = model; this.RightExpressionView = new PropertyReferenceView((PropertyReferenceViewModel)this.RightExpression); } else if (selectedExpression is ParameterReferenceViewModel) { this.RightExpressionView = new ParameterReferenceView((ParameterReferenceViewModel)this.RightExpression); } }
public UserControl Build(HermesViewModel parent, BooleanFunction model) { if (model == null) { return(null); } if (model is ComparisonOperator) { ComparisonOperatorViewModel viewModel = new ComparisonOperatorViewModel(parent, (ComparisonOperator)model); _View = new ComparisonOperatorView(viewModel); } else if (model is BooleanOperator) { BooleanOperator bo = (BooleanOperator)model; BooleanOperatorViewModel viewModel = new BooleanOperatorViewModel(parent, bo); List <BooleanFunctionViewModel> ovms = new List <BooleanFunctionViewModel>(); foreach (BooleanFunction f in bo.Operands) { ComparisonOperatorViewModel covm = new ComparisonOperatorViewModel(viewModel, (ComparisonOperator)f); ovms.Add(covm); } viewModel.Operands = new ObservableCollection <BooleanFunctionViewModel>(ovms); _View = new BooleanOperatorView(viewModel); } return(_View); }
public PropertyExpressionViewModel(HermesViewModel parent, PropertyExpression model) : base(parent, model) { this.RemovePropertyCommand = new DelegateCommand(this.RemoveProperty); this.OpenPropertySelectionDialogCommand = new DelegateCommand(this.OpenPropertySelectionDialog); this.IntializeViewModel(model); }
public BooleanOperatorViewModel(HermesViewModel parent, BooleanOperator model) : base(parent, model) { this.IntitializeViewModel(model); this.AddComparisonOperatorCommand = new DelegateCommand(this.AddComparisonOperator); this.AddInnerBooleanOperatorCommand = new DelegateCommand(this.AddInnerBooleanOperator); this.AddOuterBooleanOperatorCommand = new DelegateCommand(this.AddOuterBooleanOperator); this.RemoveBooleanOperatorCommand = new DelegateCommand(this.RemoveBooleanOperator); }
public ParameterExpressionViewModel(HermesViewModel parent, ParameterExpression model) : base(parent, model) { InitializeViewModel(model); this.ClearParameterCommand = new DelegateCommand(this.ClearParameter); this.RemoveParameterCommand = new DelegateCommand(this.RemoveParameter); this.OpenTypeSelectionDialogCommand = new DelegateCommand(this.OpenTypeSelectionDialog); this.OpenReferenceObjectDialogCommand = new DelegateCommand(this.OpenReferenceObjectDialog); }
public BooleanExpressionViewModel(HermesViewModel parent, string clause) : base(parent) { if (parent == null) { throw new ArgumentNullException(); } this.Clause = clause; GetModelFromParent(); this.InitializeViewModel(); this.AddNewConditionCommand = new DelegateCommand(this.AddNewCondition); }
public SelectStatementViewModel GetSelectStatementViewModel(HermesViewModel child) { if (child is SelectStatementViewModel) { return((SelectStatementViewModel)child); } HermesViewModel parent = child.Parent; while (parent != null && !(parent is SelectStatementViewModel)) { parent = parent.Parent; } return((parent == null) ? null : (SelectStatementViewModel)parent); }
public QueryExpressionViewModel GetQueryExpressionViewModel(HermesViewModel child) { if (child is QueryExpressionViewModel) { return((QueryExpressionViewModel)child); } HermesViewModel parent = child.Parent; while (parent != null && !(parent is QueryExpressionViewModel)) { parent = parent.Parent; } return((parent == null) ? null : (QueryExpressionViewModel)parent); }
public QueryExpressionViewModel(HermesViewModel parent, QueryExpression model) : base(parent, model) { this.TypeSelectionDialog = new InteractionRequest <Confirmation>(); this.ReferenceObjectSelectionDialog = new InteractionRequest <Confirmation>(); this.InitializeViewModel(model); this.AddNewParameterCommand = new DelegateCommand(this.AddNewParameter); this.RemoveParameterCommand = new DelegateCommand <string>(this.RemoveParameter); this.ShowSQLCommand = new DelegateCommand(this.ShowSQL); this.ShowJSONCommand = new DelegateCommand(this.ShowJSON); this.SaveQueryCommand = new DelegateCommand(this.SaveQuery); this.ExecuteQueryCommand = new DelegateCommand(this.ExecuteQuery); }
public SelectStatementViewModel(HermesViewModel parent, SelectStatement model) : base(parent, model) { this.Tables = new ObservableCollection <TableExpressionViewModel>(); this.Fields = new ObservableCollection <PropertyExpressionViewModel>(); this.InitializeViewModel(model); this.WhereClause = new BooleanExpressionViewModel(this, "WHERE"); if (model.WHERE != null) { this.WhereClause.Model = model.WHERE; } this.AddTableCommand = new DelegateCommand <Entity>(this.OnAddTable); this.AddPropertyCommand = new DelegateCommand(this.OnAddProperty); }
public TableExpressionViewModel(HermesViewModel parent, TableExpression model) : base(parent, model) { }
public PropertyReferenceViewModel(HermesViewModel parent, TableExpressionViewModel table, PropertyReference model) : base(parent, model) { this.Table = table; }
public JoinExpressionViewModel(HermesViewModel parent, TableExpression model) : base(parent, model) { //this.Filter = new BooleanExpressionViewModel(this, "ON"); }
public ParameterReferenceViewModel GetParameterReferenceViewModel(HermesViewModel parent) { return(new ParameterReferenceViewModel(parent, (ParameterExpression)this.Model)); }
public BooleanFunctionViewModel(HermesViewModel parent, BooleanFunction model) : base(parent, model) { }
public ParameterReferenceViewModel(HermesViewModel parent, ParameterExpression model) : base(parent, model) { }
private void AddOuterBooleanOperator() { BooleanOperator model = this.Model as BooleanOperator; if (model == null) { return; } // 0. Remember the parent of this node HermesModel consumer = model.Consumer; HermesViewModel parentVM = this.Parent; int index_to_replace = -1; if (consumer is BooleanOperator) { index_to_replace = ((BooleanOperator)consumer).Operands.IndexOf(model); if (index_to_replace == -1) { throw new ArgumentOutOfRangeException("Model is broken!"); } } // 1. Create new node and it's VM which will substitute this current node BooleanOperator substitute = new BooleanOperator(consumer) { Name = BooleanFunction.OR }; substitute.AddChild(model); BooleanOperatorViewModel substituteVM = new BooleanOperatorViewModel(parentVM, substitute); this.Parent = substituteVM; // 2. Create new child and it's VM consumed by substitute BooleanOperator child = new BooleanOperator(substitute); substitute.AddChild(child); BooleanOperatorViewModel childVM = new BooleanOperatorViewModel(substituteVM, child); // 3. Add new comparison operator and it's VM to new born child ComparisonOperator gift = new ComparisonOperator(child); child.AddChild(gift); ComparisonOperatorViewModel giftVM = new ComparisonOperatorViewModel(childVM, gift); childVM.Operands = new ObservableCollection <BooleanFunctionViewModel>() { giftVM }; // 4. Fill substitute VM with operands substituteVM.Operands = new ObservableCollection <BooleanFunctionViewModel>() { this, childVM }; // 5. Substitute this current node at parent VM and it's model if (consumer is BooleanOperator) { ((BooleanOperator)consumer).Operands.RemoveAt(index_to_replace); ((BooleanOperator)consumer).Operands.Insert(index_to_replace, substitute); index_to_replace = ((BooleanOperatorViewModel)parentVM).Operands.IndexOf(this); if (index_to_replace > -1) { ((BooleanOperatorViewModel)parentVM).Operands.RemoveAt(index_to_replace); ((BooleanOperatorViewModel)parentVM).Operands.Insert(index_to_replace, substituteVM); } } else if (parentVM is BooleanExpressionViewModel) { ((BooleanExpressionViewModel)parentVM).SetBooleanExpression(substituteVM); } }
public HermesViewModel(HermesViewModel parent) : base() { this.Parent = parent; }
public HermesViewModel(HermesViewModel parent, HermesModel model) : this(parent) { this.Model = model; }