示例#1
0
        public override void Execute()
        {
            base.Execute();

            var name = new TypeTextOrCancelDialog("ANO Concept Name", "Name", 500, "ANOConceptName");

            if (name.ShowDialog() == DialogResult.OK)
            {
                var suffix = new TypeTextOrCancelDialog("Type Concept Suffix", "Suffix", 5, "_X");
                if (suffix.ShowDialog() == DialogResult.OK)
                {
                    var n = name.ResultText;

                    if (!n.StartsWith("ANO"))
                    {
                        n = "ANO" + n;
                    }

                    var s = suffix.ResultText.Trim('_');

                    var anoTable = new ANOTable(Activator.RepositoryLocator.CatalogueRepository, (ExternalDatabaseServer)_anoStoreServer, n, s);
                    Publish(anoTable);
                    Activate(anoTable);
                }
            }
        }
示例#2
0
        public void Test_TypeTextOrCancelDialog_LargeStrings()
        {
            StringBuilder sb = new StringBuilder();

            //send TypeTextOrCancelDialog a million characters
            for (int i = 0; i < 1_000_000; i++)
            {
                sb.Append("f");
            }

            var s = sb.ToString();

            var dlg = new TypeTextOrCancelDialog(s, s, 5000);

            //pretend like we launched it
            LastUserInterfaceLaunched = dlg;

            //the title and body should be a reasonable length
            Assert.AreEqual(WideMessageBox.MAX_LENGTH_TITLE, dlg.Text.Length);
            Assert.AreEqual(WideMessageBox.MAX_LENGTH_BODY, GetControl <TextBox>()[1].Text.Length);

            //dialog shouldn't go thinner than 540 or wider than 840 pixels
            Assert.GreaterOrEqual(dlg.Width, 540);
            Assert.LessOrEqual(dlg.Width, 840);
        }
示例#3
0
        public override void Execute()
        {
            base.Execute();

            if (_file == null)
            {
                if (_taskType == ProcessTaskType.SQLFile)
                {
                    var dialog = new TypeTextOrCancelDialog("Enter a name for the SQL file", "File name", 100, "myscript.sql");
                    if (dialog.ShowDialog() == DialogResult.OK && !string.IsNullOrWhiteSpace(dialog.ResultText))
                    {
                        var target = Path.Combine(_LoadDirectory.ExecutablesPath.FullName, dialog.ResultText);

                        if (!target.EndsWith(".sql"))
                        {
                            target += ".sql";
                        }

                        //create it if it doesn't exist
                        if (!File.Exists(target))
                        {
                            File.WriteAllText(target, "/*todo Type some SQL*/");
                        }

                        _file = new FileInfo(target);
                    }
                    else
                    {
                        return;     //user cancelled
                    }
                }
                else if (_taskType == ProcessTaskType.Executable)
                {
                    var dialog = new OpenFileDialog();
                    dialog.Filter          = "Executables|*.exe";
                    dialog.CheckFileExists = true;

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        _file = new FileInfo(dialog.FileName);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Unexpected _taskType:" + _taskType);
                }
            }

            var task = new ProcessTask((ICatalogueRepository)_loadMetadata.Repository, _loadMetadata, _loadStage);

            task.ProcessTaskType = _taskType;
            task.Path            = _file.FullName;
            SaveAndShow(task);
        }
示例#4
0
        public override bool TypeText(string header, string prompt, int maxLength, string initialText, out string text, bool requireSaneHeaderText)
        {
            var textTyper = new TypeTextOrCancelDialog(header, prompt, maxLength, initialText, allowBlankText: false, multiLine: maxLength > 1000)
            {
                RequireSaneHeaderText = requireSaneHeaderText
            };

            text = textTyper.ShowDialog() == DialogResult.OK ? textTyper.ResultText : null;
            return(!string.IsNullOrWhiteSpace(text));
        }
示例#5
0
        /// <summary>
        /// Prompts the user to type in some text (up to a maximum length).  Returns true if they supplied some text or false if they didn't or it was blank/cancelled etc
        /// </summary>
        /// <param name="header"></param>
        /// <param name="prompt"></param>
        /// <param name="maxLength"></param>
        /// <param name="initialText"></param>
        /// <param name="text"></param>
        /// <param name="requireSaneHeaderText"></param>
        /// <returns></returns>
        protected bool TypeText(string header, string prompt, int maxLength, string initialText, out string text, bool requireSaneHeaderText = false)
        {
            var textTyper = new TypeTextOrCancelDialog(header, prompt, maxLength, initialText)
            {
                RequireSaneHeaderText = requireSaneHeaderText
            };

            text = textTyper.ShowDialog() == DialogResult.OK ? textTyper.ResultText : null;
            return(!string.IsNullOrWhiteSpace(text));
        }
        public override void Execute()
        {
            base.Execute();
            var dialog = new TypeTextOrCancelDialog("Name for package", "Name", 500);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var p = new ExtractableDataSetPackage(Activator.RepositoryLocator.DataExportRepository, dialog.ResultText);
                Publish(p);
            }
        }
示例#7
0
        protected override bool SelectValueTypeImpl(DialogArgs args, Type paramType, object initialValue, out object chosen)
        {
            //whatever else it is use string
            var typeTextDialog = new TypeTextOrCancelDialog(args, 1000, initialValue?.ToString());

            if (typeTextDialog.ShowDialog() == DialogResult.OK)
            {
                chosen = UsefulStuff.ChangeType(typeTextDialog.ResultText, paramType);
                return(true);
            }

            chosen = null;
            return(false);
        }
示例#8
0
        public void Test_TypeTextOrCancelDialog_TinyStrings()
        {
            var dlg = new TypeTextOrCancelDialog("f", "m", 5000);

            //pretend like we launched it
            LastUserInterfaceLaunched = dlg;

            //the title and body should be a reasonable length
            Assert.AreEqual(1, dlg.Text.Length);
            Assert.AreEqual(1, GetControl <Label>().Single().Text.Length);

            //dialog shouldn't go thinner than 460 pixels
            Assert.AreEqual(460, dlg.Width);
        }
示例#9
0
        private void AddNewDashboard()
        {
            var dialog = new TypeTextOrCancelDialog("Dashboard Name", "Name", 100, null, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var dash = new DashboardLayout(_manager.RepositoryLocator.CatalogueRepository, dialog.ResultText);

                var cmd = new ExecuteCommandActivate(_manager.ActivateItems, dash);
                cmd.Execute();

                ReCreateDropDowns();
            }
        }
示例#10
0
        public void Test_TypeTextOrCancelDialog_TinyStrings()
        {
            var dlg = new TypeTextOrCancelDialog("f", "m", 5000);

            //pretend like we launched it
            LastUserInterfaceLaunched = dlg;

            //the title and body should be a reasonable length
            Assert.AreEqual(1, dlg.Text.Length);
            Assert.AreEqual(1, GetControl <TextBox>()[1].Text.Length);

            //dialog shouldn't go thinner than 540 or wider than 840 pixels
            Assert.GreaterOrEqual(dlg.Width, 540);
            Assert.LessOrEqual(dlg.Width, 840);
        }
示例#11
0
        private void AddNewLayout()
        {
            string xml = _manager.MainForm.GetCurrentLayoutXml();

            var dialog = new TypeTextOrCancelDialog("Layout Name", "Name", 100, null, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var layout = new WindowLayout(_manager.RepositoryLocator.CatalogueRepository, dialog.ResultText, xml);

                var cmd = new ExecuteCommandActivate(_manager.ActivateItems, layout);
                cmd.Execute();

                ReCreateDropDowns();
            }
        }
示例#12
0
        private void miAddParameter_Click(object sender, EventArgs e)
        {
            Random r = new Random();

#pragma warning disable SCS0005 // Weak random generator: This is only used to create an initial value for a parameter.
            var dialog = new TypeTextOrCancelDialog("Parameter Name", "Name", 100, "@MyParam" + r.Next());
#pragma warning restore SCS0005 // Weak random generator
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var newParameter = Options.CreateNewParameter(dialog.ResultText.Trim());

                Options.ParameterManager.ParametersFoundSoFarInQueryGeneration[Options.CurrentLevel].Add(newParameter);

                RefreshParametersFromDatabase();
            }
        }
        public override void Execute()
        {
            base.Execute();

            string name     = null;
            string dataType = null;

            if (_prototypes == null)
            {
                var varcharMaxDataType = _tableInfo.GetQuerySyntaxHelper().TypeTranslater.GetSQLDBTypeForCSharpType(new DatabaseTypeRequest(typeof(string), int.MaxValue));

                var textDialog = new TypeTextOrCancelDialog("Column Name", "Enter name for column (this should NOT include any qualifiers e.g. database name)", 300);
                if (textDialog.ShowDialog() == DialogResult.OK)
                {
                    name = textDialog.ResultText;
                }
                else
                {
                    return;
                }

                textDialog = new TypeTextOrCancelDialog("Column DataType", "Enter data type for column (e.g. 'varchar(10)')", 300, varcharMaxDataType);
                if (textDialog.ShowDialog() == DialogResult.OK)
                {
                    dataType = textDialog.ResultText;
                }
                else
                {
                    return;
                }

                var created = Create(name, dataType);
                Publish();
                Emphasise(created);
                Activate(created);
            }
            else
            {
                foreach (ColumnInfo prototype in _prototypes)
                {
                    Create(prototype.GetRuntimeName(), prototype.Data_type);
                }

                Publish();
            }
        }
示例#14
0
        public override void Execute()
        {
            base.Execute();

            if (!_explicitNewValuePassed)
            {
                var dialog = new TypeTextOrCancelDialog("Rename " + _nameable.GetType().Name, "Name", 2000, _nameable.Name);
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    while (UsefulStuff.IsBadName(dialog.ResultText))
                    {
                        if (YesNo("Name contains illegal characters, do you want to use it anyway?", "Bad Name"))
                        {
                            //user wants to use the name anyway
                            break;
                        }

                        //user does not want to use the bad name

                        //type a new one then
                        dialog = new TypeTextOrCancelDialog("Rename " + _nameable.GetType().Name, "Name", 2000, dialog.ResultText);

                        //no? in that case lets just give up altogether
                        if (dialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                    }
                    _newValue = dialog.ResultText;
                }
                else
                {
                    return;
                }
            }

            _nameable.Name = _newValue;
            EnsureNameIfCohortIdentificationAggregate();

            _nameable.SaveToDatabase();
            Publish((DatabaseEntity)_nameable);
        }
示例#15
0
        void mi_ChooseFileSeparator_Click(object sender, EventArgs e)
        {
            ExtractionConfiguration toSetDescriptionOn = Activator.RepositoryLocator.DataExportRepository.GetObjectByID <ExtractionConfiguration>(_rightClickedRowExtractionConfigurationID);

            if (toSetDescriptionOn.IsReleased)
            {
                return;
            }

            TypeTextOrCancelDialog dialog = new TypeTextOrCancelDialog("Separator", "Choose a character(s) separator", 3, toSetDescriptionOn.Separator);

            dialog.ShowDialog(this);

            if (dialog.DialogResult == DialogResult.OK)
            {
                toSetDescriptionOn.Separator = dialog.ResultText;
                toSetDescriptionOn.SaveToDatabase();
                RefreshLists();
            }
        }
示例#16
0
        void mi_SetDescription_Click(object sender, EventArgs e)
        {
            ExtractionConfiguration toSetDescriptionOn = Activator.RepositoryLocator.DataExportRepository.GetObjectByID <ExtractionConfiguration>(_rightClickedRowExtractionConfigurationID);

            if (toSetDescriptionOn.IsReleased)
            {
                return;
            }

            TypeTextOrCancelDialog dialog = new TypeTextOrCancelDialog("Description", "Enter a Description for the Extraction:", 1000, toSetDescriptionOn.Description);

            dialog.ShowDialog(this);

            if (dialog.DialogResult == DialogResult.OK)
            {
                toSetDescriptionOn.Description = dialog.ResultText;
                toSetDescriptionOn.SaveToDatabase();
                RefreshLists();
            }
        }
        public override void Execute()
        {
            base.Execute();

            TypeTextOrCancelDialog dialog = new TypeTextOrCancelDialog("Permission Window Name", "Enter name for the PermissionWindow e.g. 'Nightly Loads'", 1000);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string windowText = dialog.ResultText;
                var    newWindow  = new PermissionWindow(Activator.RepositoryLocator.CatalogueRepository);
                newWindow.Name = windowText;
                newWindow.SaveToDatabase();

                if (_cacheProgressToSetOnIfAny != null)
                {
                    new ExecuteCommandSetPermissionWindow(Activator, _cacheProgressToSetOnIfAny).SetTarget(newWindow).Execute();
                }

                Publish(newWindow);
                Activate(newWindow);
            }
        }
示例#18
0
        private void chart1_MouseUp(object sender, MouseEventArgs e)
        {
            if (!annotating)
            {
                return;
            }

            var pointEndX = chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X);
            var pointEndY = chart1.ChartAreas[0].AxisY.PixelPositionToValue(e.Y);


            TypeTextOrCancelDialog inputBox = new TypeTextOrCancelDialog("Enter Annotation Text", "Type some annotation text (will be saved to the database for other data analysts to see)", 500);

            if (DialogResult.OK == inputBox.ShowDialog())
            {
                //create new annotation in the database
                new DQEGraphAnnotation(_currentEvaluation.DQERepository, pointStartX, pointStartY, pointEndX, pointEndY, inputBox.ResultText, _currentEvaluation, DQEGraphType.TimePeriodicityGraph, _pivotCategoryValue);

                //refresh the annotations
                AddUserAnnotations(_currentEvaluation);
            }
        }
示例#19
0
        public void SetOperationTo(SetOperation newOperation)
        {
            var oldOperation = _container.Operation;

            _container.Operation = newOperation;

            //if the old name was UNION and we are changing to INTERSECT Operation then we should probably change the Name too! even if they have something like 'INTERSECT the people who are big and small' and they change to UNION we want it to be changed to 'UNION the people who are big and small'
            if (_container.Name.StartsWith(oldOperation.ToString()))
            {
                _container.Name = newOperation + _container.Name.Substring(oldOperation.ToString().Length);
            }
            else
            {
                var dialog = new TypeTextOrCancelDialog("New name for container?", "You have changed the operation, do you want to give it a new description?", 1000, _container.Name);

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    _container.Name = dialog.ResultText;
                }
            }
            _container.SaveToDatabase();
            Publish(_container);
        }
示例#20
0
        private object GetValueForParameterOfType(ParameterInfo parameterInfo, Type paramType)
        {
            if (typeof(ICatalogueRepository).IsAssignableFrom(paramType))
            {
                return(Activator.RepositoryLocator.CatalogueRepository);
            }

            if (typeof(IDataExportRepository).IsAssignableFrom(paramType))
            {
                return(Activator.RepositoryLocator.DataExportRepository);
            }

            if (typeof(IRDMPPlatformRepositoryServiceLocator).IsAssignableFrom(paramType))
            {
                return(Activator.RepositoryLocator);
            }

            if (typeof(IActivateItems).IsAssignableFrom(paramType))
            {
                return(Activator);
            }

            if (typeof(DirectoryInfo).IsAssignableFrom(paramType))
            {
                var fb = new FolderBrowserDialog();
                if (fb.ShowDialog() == DialogResult.OK)
                {
                    return(new DirectoryInfo(fb.SelectedPath));
                }

                return(null);
            }

            if (typeof(DatabaseEntity).IsAssignableFrom(paramType))
            {
                IMapsDirectlyToDatabaseTable[] availableObjects;
                if (Activator.RepositoryLocator.CatalogueRepository.SupportsObjectType(paramType))
                {
                    availableObjects = Activator.RepositoryLocator.CatalogueRepository.GetAllObjects(paramType).ToArray();
                }
                else if (Activator.RepositoryLocator.DataExportRepository.SupportsObjectType(paramType))
                {
                    availableObjects = Activator.RepositoryLocator.DataExportRepository.GetAllObjects(paramType).ToArray();
                }
                else
                {
                    return(null);
                }


                return(PickOne(parameterInfo, paramType, availableObjects));
            }

            if (typeof(IMightBeDeprecated).IsAssignableFrom(paramType))
            {
                return(PickOne(parameterInfo, paramType,
                               Activator.CoreChildProvider.GetAllSearchables()
                               .Keys.OfType <IMightBeDeprecated>()
                               .Cast <IMapsDirectlyToDatabaseTable>()
                               .ToArray()));
            }

            if (typeof(ICheckable).IsAssignableFrom(paramType))
            {
                return(PickOne(parameterInfo, paramType, Activator.CoreChildProvider.GetAllSearchables()
                               .Keys.OfType <ICheckable>()
                               .Cast <IMapsDirectlyToDatabaseTable>()
                               .Where(paramType.IsInstanceOfType)
                               .ToArray()));
            }

            if (parameterInfo.HasDefaultValue)
            {
                return(parameterInfo.DefaultValue);
            }

            if (paramType.IsValueType && !typeof(Enum).IsAssignableFrom(paramType))
            {
                var typeTextDialog = new TypeTextOrCancelDialog("Enter Value", "Enter value for '" + parameterInfo.Name + "' (" + paramType.Name + ")", 1000);

                if (typeTextDialog.ShowDialog() == DialogResult.OK)
                {
                    return(Convert.ChangeType(typeTextDialog.ResultText, paramType));
                }
            }

            return(null);
        }