public TableEditorPage(SelectedContentArgs SelectedContentArgs, string startKeyWord, string endKeyWord, string KeyWordForTableLocationIndication = null) { InitializeComponent(); GapBetweenFoldingOffsetAndTableLocaionIndication = 0; this.textEditor = SelectedContentArgs.TextEditor; this.foldingSection = SelectedContentArgs.GetFoldingsAtCaretPosition()[0]; int CaretLocation = SelectedContentArgs.GetCaretPosition(); FoldingOffset = SelectedContentArgs.GetFoldingOffSet(); if (KeyWordForTableLocationIndication != null) { int indexOfKeyWordForIndication = foldingSection.TextContent.IndexOf(KeyWordForTableLocationIndication); if (KeyWordForTableLocationIndication != null && indexOfKeyWordForIndication != -1 && CaretLocation - FoldingOffset > indexOfKeyWordForIndication) { WorkingSection = foldingSection.TextContent.Substring(indexOfKeyWordForIndication); GapBetweenFoldingOffsetAndTableLocaionIndication = foldingSection.TextContent.Length - WorkingSection.Length; } else { WorkingSection = foldingSection.TextContent; } } else { WorkingSection = foldingSection.TextContent; } StartKeyWord = startKeyWord; EndKeyWord = endKeyWord; InitTable(); }
private Page GetPageFor(SelectedContentArgs SelectedContentArgs) { string txt = SelectedContentArgs.TextEditor.Text.Substring(SelectedContentArgs.StartPos, SelectedContentArgs.Length); p = null; if (txt.StartsWith("{Var Name=")) { p = new ValueExpressionVariableEditorPage(mContext, SelectedContentArgs); } if (txt.StartsWith("{DS Name=")) { p = new ActDataSourcePage(SelectedContentArgs); } if (txt.StartsWith("{FD Object=")) { Tuple <GingerCore.ValueExpression.eFlowDetailsObjects, string> expParams = GingerCore.ValueExpression.GetFlowDetailsParams(txt); if (expParams != null) { p = new ValueExpressionFlowDetailsEditorPage(mContext, SelectedContentArgs, expParams.Item1, expParams.Item2); } } if (txt.StartsWith("{EnvURL App=")) { //TODO: impl get page for Env } // TODO: if we are on {Actual} - show help to explain... return(p); }
public ValueExpressionVariableEditorPage(Context context, SelectedContentArgs SelectedContentArgs) { InitializeComponent(); mContext = context; mSelectedContentArgs = SelectedContentArgs; List <string> lst = new List <string>(); // Add the variables from solution, current BF and current activity foreach (VariableBase v in WorkSpace.UserProfile.Solution.Variables) { lst.Add(v.Name); } foreach (VariableBase v in mContext.BusinessFlow.Variables) { lst.Add(v.Name); } foreach (VariableBase v in mContext.BusinessFlow.CurrentActivity.Variables) { lst.Add(v.Name); } VarsList.ItemsSource = lst; }
private void TextArea_TextEntered(object sender, System.Windows.Input.TextCompositionEventArgs e) { completionWindow = new CompletionWindow(textEditor.TextArea); SelectedContentArgs args = new SelectedContentArgs(); args.TextEditor = textEditor; //TODO: fill the rest of the args List <ICompletionData> data = mTextEditor.GetCompletionData(e.Text, args); if (data != null && data.Count() > 0) { IList <ICompletionData> cdata = completionWindow.CompletionList.CompletionData; foreach (ICompletionData TCD in data) { cdata.Add(TCD); } completionWindow.Width = completionWindow.Width + (Gherkin.GherkinDcoumentEditor.CompletionWindowSize * 2.5); completionWindow.CloseAutomatically = true; completionWindow.Show(); completionWindow.Closed += delegate { ICompletionData ICD = (ICompletionData)completionWindow.CompletionList.ListBox.SelectedItem; completionWindow = null; }; } }
public GherkinTableEditorPage(SelectedContentArgs SelectedContentArgs) { InitializeComponent(); this.textEditor = SelectedContentArgs.TextEditor; this.foldingSection = SelectedContentArgs.GetFoldingsAtCaretPosition()[0]; InitTable(); }
public override List <ICompletionData> GetCompletionData(string txt, SelectedContentArgs SelectedContentArgs) { List <ICompletionData> list = new List <ICompletionData>(); if (txt == "{") { list.Add(new TextCompletionData("{Var Name=}", "Variable")); list.Add(new TextCompletionData("{VBS Eval=}", "VB Script Evaluate")); AddVars(list); } return(list); }
public override Page GetSelectedContentPageEditor(SelectedContentArgs SelectedContentArgs) { // SelectedContentArgs.TextEditor.Document. //TODO: use SelectedContentArgs.TextEditor.Document - documents function is better //start by searching the closest { to the caret offset int i1 = SelectedContentArgs.TextEditor.CaretOffset; int closestpos = -1; while (i1 >= 0 && i1 < SelectedContentArgs.TextEditor.Text.Length) { string c = SelectedContentArgs.TextEditor.Text.Substring(i1, 1); if (c == "{") { closestpos = i1; break; } if (c == "}" && i1 != SelectedContentArgs.TextEditor.CaretOffset) // we stop if we found } - except for the first char - in case the user click on the closing } of exp { break; } i1--; } if (closestpos == -1) { return(null); } // find the = after the closest { pos int i0 = SelectedContentArgs.TextEditor.Text.IndexOf("}", closestpos); // Verify caret are in between { } if (closestpos < SelectedContentArgs.TextEditor.CaretOffset && i0 >= SelectedContentArgs.TextEditor.CaretOffset) { int i2 = SelectedContentArgs.TextEditor.Text.IndexOf("=", closestpos); if (i2 >= 0) { SelectedContentArgs.StartPos = closestpos; SelectedContentArgs.EndPos = i0; Page p = GetPageFor(SelectedContentArgs); return(p); } } return(null); }
//TODO: looks liek too many calls, even the the caret didn't move, can first check if pos changed otherwise return - keep last private void Caret_PositionChanged(object sender, EventArgs e) { SelectedContentArgs args = new SelectedContentArgs(); args.TextEditor = this.textEditor; args.FoldingManager = mFoldingManager; if (mTextEditor == null) { return; } Page p = mTextEditor.GetSelectedContentPageEditor(args); if (p != null) { SelectionEditorFrame.Content = p; SelectionEditorFrame.Visibility = Visibility.Visible; if (mLastEditPageRowHeight.Value == 0) { mLastEditPageRowHeight = new GridLength(150); } EditPageRow.Height = mLastEditPageRowHeight; SelectionEditorFrameSplitter.Visibility = Visibility.Visible; } else { if (SelectionEditorFrame.Visibility == Visibility.Visible) { // Save the last width so we can restore to same size if (EditPageRow.Height.Value > 0) { mLastEditPageRowHeight = new GridLength(EditPageRow.ActualHeight); SelectionEditorFrameSplitter.Visibility = Visibility.Visible; } SelectionEditorFrame.Visibility = Visibility.Collapsed; SelectionEditorFrameSplitter.Visibility = Visibility.Collapsed; EditPageRow.Height = new GridLength(0); } } }
public override Page GetSelectedContentPageEditor(SelectedContentArgs SelectedContentArgs) { ReadOnlyCollection <FoldingSection> list = SelectedContentArgs.GetFoldingsAtCaretPosition(); if (list == null) { return(null); } if (list.Count > 0) { string txt = list[0].TextContent; if (txt.Contains("Examples:")) { //TODO: check if 0 or something else GherkinTableEditorPage p = new GherkinTableEditorPage(SelectedContentArgs); return(p); } } return(null); }
private Page GetPageFor(SelectedContentArgs SelectedContentArgs) { string txt = SelectedContentArgs.TextEditor.Text.Substring(SelectedContentArgs.StartPos, SelectedContentArgs.Length); if (txt.StartsWith("{Var Name=")) { p = new ValueExpressionVariableEditorPage(mContext, SelectedContentArgs); } if (txt.StartsWith("{DS Name=")) { p = new ActDataSourcePage(SelectedContentArgs); } if (txt.StartsWith("{EnvURL App=")) { //TODO: impl get page for Env } // TODO: if we are on {Actual} - show help to explain... return(p); }
public ValueExpressionFlowDetailsEditorPage(Context context, SelectedContentArgs SelectedContentArgs, GingerCore.ValueExpression.eFlowDetailsObjects obj, string field) { InitializeComponent(); mContext = context; mSelectedContentArgs = SelectedContentArgs; mObj = obj; List <string> lst = new List <string>(); PropertyInfo[] properties = null; FieldInfo[] fields = null; Type objType; switch (mObj) { case GingerCore.ValueExpression.eFlowDetailsObjects.Solution: objType = typeof(Ginger.SolutionGeneral.Solution); break; case GingerCore.ValueExpression.eFlowDetailsObjects.Environment: objType = typeof(ProjEnvironment); break; case GingerCore.ValueExpression.eFlowDetailsObjects.Runset: objType = typeof(RunSetConfig); break; case GingerCore.ValueExpression.eFlowDetailsObjects.Runner: objType = typeof(GingerExecutionEngine); break; case GingerCore.ValueExpression.eFlowDetailsObjects.BusinessFlow: case GingerCore.ValueExpression.eFlowDetailsObjects.PreviousBusinessFlow: case GingerCore.ValueExpression.eFlowDetailsObjects.LastFailedBusinessFlow: objType = typeof(BusinessFlow); break; case GingerCore.ValueExpression.eFlowDetailsObjects.ActivitiesGroup: case GingerCore.ValueExpression.eFlowDetailsObjects.ErrorHandlerOriginActivitiesGroup: objType = typeof(ActivitiesGroup); break; case GingerCore.ValueExpression.eFlowDetailsObjects.Activity: case GingerCore.ValueExpression.eFlowDetailsObjects.PreviousActivity: case GingerCore.ValueExpression.eFlowDetailsObjects.ErrorHandlerOriginActivity: case GingerCore.ValueExpression.eFlowDetailsObjects.LastFailedActivity: objType = typeof(Activity); break; case GingerCore.ValueExpression.eFlowDetailsObjects.Action: case GingerCore.ValueExpression.eFlowDetailsObjects.PreviousAction: case GingerCore.ValueExpression.eFlowDetailsObjects.LastFailedAction: case GingerCore.ValueExpression.eFlowDetailsObjects.ErrorHandlerOriginAction: objType = typeof(GingerCore.Actions.Act); break; default: throw new KeyNotFoundException(); } properties = objType.GetProperties(); fields = objType.GetFields(); if (properties != null) { foreach (PropertyInfo prop in properties) { if (!typeof(IObservableList).IsAssignableFrom(prop.PropertyType)) { lst.Add(prop.Name); } } } if (fields != null) { foreach (FieldInfo f in fields) { if (!typeof(IObservableList).IsAssignableFrom(f.FieldType)) { lst.Add(f.Name); } } } fieldList.ItemsSource = lst.OrderBy(x => x).ToList(); }
public override List <ICompletionData> GetCompletionData(string txt, SelectedContentArgs SelectedContentArgs) { return(null); }
public override Page GetSelectedContentPageEditor(SelectedContentArgs SelectedContentArgs) { return(null); }
public ValueExpressionDDSEditorPage(SelectedContentArgs selectedContentArgs) { InitializeComponent(); }
public override Page GetSelectedContentPageEditor(SelectedContentArgs SelectedContentArgs) { throw new NotImplementedException(); }
public abstract Page GetSelectedContentPageEditor(SelectedContentArgs SelectedContentArgs);
public abstract List <ICompletionData> GetCompletionData(string txt, SelectedContentArgs SelectedContentArgs);
public override List <ICompletionData> GetCompletionData(string txt, SelectedContentArgs SelectedContentArgs) { List <ICompletionData> list = new List <ICompletionData>(); //TODO: fix me - only when in the beginning of line - allow lower case too string CurrentLine = SelectedContentArgs.CaretLineText(); while (CurrentLine.StartsWith(" ") || CurrentLine.StartsWith("\t")) { CurrentLine = CurrentLine.Substring(1); } bool IsAtStartOfLine = CurrentLine.Length == 1; bool IsAfterKeyWord = CurrentLine.StartsWith("Given") || CurrentLine.StartsWith("When") || CurrentLine.StartsWith("Then") || CurrentLine.StartsWith("And"); if (SelectedContentArgs.IsAtStartOfLine() || IsAtStartOfLine) { if (txt.ToUpper() == "G") { list.Add(new GherkinTextCompletionData("Given")); } if (txt.ToUpper() == "W") { list.Add(new GherkinTextCompletionData("When")); } if (txt.ToUpper() == "T") { list.Add(new GherkinTextCompletionData("Then")); } if (txt.ToUpper() == "A") { list.Add(new GherkinTextCompletionData("And")); } if (txt == " ") { list.Add(new GherkinTextCompletionData("Given")); list.Add(new GherkinTextCompletionData("When")); list.Add(new GherkinTextCompletionData("Then")); list.Add(new GherkinTextCompletionData("And")); } if (txt.ToUpper() == "S") { list.Add(new GherkinTextCompletionData("Scenario:")); list.Add(new GherkinTextCompletionData("Scenario Outline:")); } } else if (IsAfterKeyWord) { if (txt == " ") { if (OptimizedSteps != null) { foreach (GherkinStep GH in OptimizedSteps) { if (CompletionWindowSize < GH.Text.Length) { CompletionWindowSize = GH.Text.Length; } list.Add(GETVTDM(GH)); } } return(list); } while (CurrentLine.StartsWith(" ") || CurrentLine.StartsWith("\t")) { CurrentLine = CurrentLine.Substring(1); } if (CurrentLine.StartsWith("Given")) { CurrentLine = CurrentLine.Substring(5); } if (CurrentLine.StartsWith("When")) { CurrentLine = CurrentLine.Substring(4); } if (CurrentLine.StartsWith("Then")) { CurrentLine = CurrentLine.Substring(4); } if (CurrentLine.StartsWith("And")) { CurrentLine = CurrentLine.Substring(3); } while (CurrentLine.StartsWith(" ") || CurrentLine.StartsWith("\t")) { CurrentLine = CurrentLine.Substring(1); } if (CurrentLine != string.Empty && OptimizedSteps != null) { foreach (GherkinStep GH in OptimizedSteps) { if (GH.Text.ToUpper().Contains(CurrentLine.ToUpper())) { if (CompletionWindowSize < GH.Text.Length) { CompletionWindowSize = GH.Text.Length; } list.Add(GETVTDM(GH)); } } } } //TODO:: Need to check usage /*if (CurrentLine.Contains("@") && CurrentLine.LastIndexOf(" ") != -1) * CurrentLine = CurrentLine.Substring(CurrentLine.LastIndexOf(" ")); * while (CurrentLine.StartsWith(" ") || CurrentLine.StartsWith("\t")) * CurrentLine = CurrentLine.Substring(1);*/ if (CurrentLine.Contains("@")) { foreach (GherkinTag GT in OptimizedTags) { if (!CurrentLine.ToUpper().Contains(GT.Name.ToUpper())) { if (CompletionWindowSize < GT.Name.Length) { CompletionWindowSize = GT.Name.Length; } ICompletionData TCD = list.Where(x => x.Text == GT.Name).FirstOrDefault(); if (TCD == null) { list.Add(GetTagName(GT)); } } } foreach (RepositoryItemTag tag in WorkSpace.Instance.Solution.Tags) { string tagname = "@" + tag.Name; if (!CurrentLine.ToUpper().Contains(tagname.ToUpper())) { if (CompletionWindowSize < tag.Name.Length) { CompletionWindowSize = tag.Name.Length; } ICompletionData TCD = list.Where(x => x.Text == tagname).FirstOrDefault(); if (TCD == null) { list.Add(GetTagName(tag)); } } } } //TODO: fix me - show only in the start of line after Given/When then... //if (txt == "I") //{ // foreach (GherkinStep GH in OptimizedSteps) // { // //if (CompletionWindowSize < GH.Text.Length) { CompletionWindowSize = GH.Text.Length; } // list.Add(GETVTDM(GH)); // } //} return(list); }