예제 #1
0
        public void SetUp()
        {
            _editor = new SqlTextEditor();

            var connectionConfiguration = ConfigurationProvider.GetConnectionConfiguration(ConfigurationProvider.ConnectionStrings[0].Name);

            _infrastructureFactory = connectionConfiguration.InfrastructureFactory;
        }
        public ContextActionTextEditorCommand(SqlTextEditor textEditor, ContextAction contextAction)
            : base(contextAction)
        {
            if (textEditor == null)
            {
                throw new ArgumentNullException(nameof(textEditor));
            }

            _textEditor = textEditor;
        }
예제 #3
0
        public static void UpdateDocument(SqlTextEditor editor, ActionExecutionContext executionContext)
        {
            var caretOffset     = editor.CaretOffset;
            var selectionLength = editor.SelectionLength;

            editor.ReplaceTextSegments(executionContext.SegmentsToReplace);

            var caretOffsetChanged = executionContext.CaretOffset != caretOffset;

            if (executionContext.SelectionLength != selectionLength)
            {
                editor.SelectionStart  = caretOffsetChanged ? executionContext.CaretOffset : editor.CaretOffset;
                editor.SelectionLength = executionContext.SelectionLength;
            }

            if (caretOffsetChanged)
            {
                editor.CaretOffset = executionContext.CaretOffset;
                editor.ScrollToCaret();
            }
        }
예제 #4
0
 public void SetUp()
 {
     _editor = new SqlTextEditor();
 }
예제 #5
0
		public ContextActionTextEditorCommand(SqlTextEditor textEditor, ContextAction contextAction)
			: base(contextAction)
		{
			if (textEditor == null)
			{
				throw new ArgumentNullException(nameof(textEditor));
			}

			_textEditor = textEditor;
		}
예제 #6
0
        public static void ExecuteEditCommand(SqlDocumentRepository documentRepository, SqlTextEditor editor, Action <ActionExecutionContext> executionHandler)
        {
            if (editor.IsReadOnly || !String.Equals(documentRepository.StatementText, editor.Text))
            {
                return;
            }

            var executionContext = ActionExecutionContext.Create(editor, documentRepository);

            try
            {
                executionHandler(executionContext);
                UpdateDocument(editor, executionContext);
            }
            catch (Exception exception)
            {
                App.LogErrorAndShowMessage(exception);
            }
        }