Ejemplo n.º 1
0
        protected void RenameColumn()
        {
            if (lvDynamicColumns.SelectedItems.Count == 1)
            {
                var dynamicColumnRow = (MainDataSet.DynamicColumnsRow)lvDynamicColumns.SelectedItems[0].Tag;

                var oldTitle = dynamicColumnRow.Title;

                var formClass = new FormEditDynamicColumn
                {
                    ViewsManager               = _views,
                    ID                         = dynamicColumnRow.ID,
                    Title                      = dynamicColumnRow.Title,
                    DynamicColumnType          = (DynamicColumnType)dynamicColumnRow.Type,
                    DisableColumnTypeSelection = true,
                    lblType                    = { Visible = false },
                    cmbType                    = { Visible = false }
                };

                if (formClass.ShowDialog() == DialogResult.OK)
                {
                    _views.MainForm.adapterDocuments.RenameDynamicColumn(dynamicColumnRow.Title, formClass.Title, dynamicColumnRow.ID, true);
                    _views.MainForm.adapterReviewMLDocumentsNew.RenameDynamicColumn(dynamicColumnRow.Title, formClass.Title, dynamicColumnRow.ID, false);

                    dynamicColumnRow.Title = formClass.Title;

                    _views.MainForm.adapterDynamicColumns.Update(dynamicColumnRow);
                    _views.MainForm.adapterDynamicColumns.Fill(_views.MainForm.datasetMain.DynamicColumns);

                    ///////////////////////////////////////////////////////////////////////////////

                    if (formClass.DynamicColumnType == DynamicColumnType.Category)
                    {
                        var svmColumnName = oldTitle + " (SVM)";
                        var svmColumn     = _views.MainForm.adapterDocuments.GetExtraColumnsCollection().FirstOrDefault(x => String.Compare(x.Name, svmColumnName, StringComparison.InvariantCultureIgnoreCase) == 0);
                        if (svmColumn != null)
                        {
                            _views.MainForm.adapterDocuments.RenameExtraColumn(svmColumn.Name, formClass.Title + " (SVM)", true);
                            _views.MainForm.adapterReviewMLDocumentsNew.RenameExtraColumn(svmColumn.Name, formClass.Title + " (SVM)", false);
                        }
                    }

                    ///////////////////////////////////////////////////////////////////////////////

                    FillColumnsList(formClass.ID);

                    _needReloadDocuments = true;
                }
            }
        }
Ejemplo n.º 2
0
        protected void AddColumn()
        {
            var formClass = new FormEditDynamicColumn();

            formClass.ViewsManager = _views;
            formClass.Title        = "New Column";

            if (formClass.ShowDialog() == DialogResult.OK)
            {
                var newColumn         = _views.MainForm.adapterDocuments.AddDynamicColumn(formClass.Title, formClass.DynamicColumnType, true);
                var newColumnReviewML = _views.MainForm.adapterReviewMLDocumentsNew.AddDynamicColumn(formClass.Title, formClass.DynamicColumnType, false);

                if (formClass.DynamicColumnType == DynamicColumnType.Category)
                {
                    _views.MainForm.adapterDocuments.AddExtraColumn(formClass.Title + " (SVM)", "INTEGER", true);
                    _views.MainForm.adapterReviewMLDocumentsNew.AddExtraColumn(formClass.Title + " (SVM)", "INTEGER", false);
                }

                ///////////////////////////////////////////////////////////////////////////////

                var order = _views.MainForm.datasetMain.DynamicColumns.Count(x => x.RowState != DataRowState.Deleted) + 1;

                _views.MainForm.adapterDynamicColumns.Insert(formClass.Title, (int)formClass.DynamicColumnType, order, String.Empty);
                _views.MainForm.adapterDynamicColumns.Fill(_views.MainForm.datasetMain.DynamicColumns);

                var newRow = _views.MainForm.datasetMain.DynamicColumns.FirstOrDefault(x => x.Title == formClass.Title);
                if (newRow != null)
                {
                    newColumn.DynamicColumnID         = newRow.ID;
                    newColumnReviewML.DynamicColumnID = newRow.ID;

                    FillColumnsList(newRow.ID);
                }
                else
                {
                    throw new Exception("Failed to add column");
                }
            }
        }
Ejemplo n.º 3
0
        protected void CloneColumn()
        {
            if (lvDynamicColumns.SelectedItems.Count != 1)
            {
                return;
            }

            var sourceDynamicColumnRow = (MainDataSet.DynamicColumnsRow)lvDynamicColumns.SelectedItems[0].Tag;
            var sourceColumnTitle      = sourceDynamicColumnRow.Title;
            var sourceColumnID         = sourceDynamicColumnRow.ID;

            var formClass = new FormEditDynamicColumn
            {
                ViewsManager               = _views,
                Title                      = sourceDynamicColumnRow.Title + " copy",
                DynamicColumnType          = (DynamicColumnType)sourceDynamicColumnRow.Type,
                DisableColumnTypeSelection = true
            };

            if (formClass.ShowDialog() == DialogResult.OK)
            {
                var newColumn         = _views.MainForm.adapterDocuments.AddDynamicColumn(formClass.Title, formClass.DynamicColumnType, true);
                var newColumnReviewML = _views.MainForm.adapterReviewMLDocumentsNew.AddDynamicColumn(formClass.Title, formClass.DynamicColumnType, false);

                ///////////////////////////////////////////////////////////////////////////////

                var order = _views.MainForm.datasetMain.DynamicColumns.Count(x => x.RowState != DataRowState.Deleted) + 1;

                var colProps = sourceDynamicColumnRow.IsPropertiesNull() ? String.Empty : sourceDynamicColumnRow.Properties;
                _views.MainForm.adapterDynamicColumns.Insert(formClass.Title, (int)formClass.DynamicColumnType, order, colProps);
                _views.MainForm.adapterDynamicColumns.Fill(_views.MainForm.datasetMain.DynamicColumns);

                var newRow = _views.MainForm.datasetMain.DynamicColumns.FirstOrDefault(x => x.Title == formClass.Title);
                if (newRow != null)
                {
                    newColumn.DynamicColumnID         = newRow.ID;
                    newColumnReviewML.DynamicColumnID = newRow.ID;

                    ///////////////////////////////////////////////////////////////////////////////

                    if (formClass.DynamicColumnType == DynamicColumnType.Category)
                    {
                        CloneCategories(sourceColumnID, sourceColumnTitle, newRow.ID, formClass.Title);
                    }

                    CloneColumnRegExps(sourceColumnID, newRow.ID);
                    CloneColumnScript(sourceColumnID, newRow.ID);
                    CloneColumnPython(sourceColumnID, newRow.ID);

                    ///////////////////////////////////////////////////////////////////////////////

                    FillColumnsList(newRow.ID);

                    _needReloadDocuments = true;
                }
                else
                {
                    throw new Exception("Failed to clone column");
                }
            }
        }