From 43633429074ea437f184d7a8317047b37c55c394 Mon Sep 17 00:00:00 2001 From: Michael Sevestre Date: Tue, 27 Oct 2020 15:50:28 -0400 Subject: [PATCH 1/3] WIP select on click: Some improvements --- .../Importer/ColumnMappingControl.Designer.cs | 1 + .../Views/Importer/ColumnMappingControl.cs | 89 +++++++++++-------- 2 files changed, 52 insertions(+), 38 deletions(-) diff --git a/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.Designer.cs b/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.Designer.cs index 4209bd110..92ddb7ed4 100644 --- a/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.Designer.cs +++ b/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.Designer.cs @@ -19,6 +19,7 @@ protected override void Dispose(bool disposing) { components.Dispose(); } + _gridViewBinder.Dispose(); base.Dispose(disposing); } diff --git a/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs b/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs index 240b18e38..150ed04eb 100644 --- a/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs +++ b/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs @@ -10,16 +10,15 @@ using DevExpress.XtraGrid.Views.Base; using DevExpress.XtraGrid.Views.Grid; using OSPSuite.Assets; -using OSPSuite.DataBinding; using OSPSuite.DataBinding.DevExpress; using OSPSuite.DataBinding.DevExpress.XtraGrid; using OSPSuite.Infrastructure.Import.Core.DataFormat; using OSPSuite.Presentation.Presenters.Importer; using OSPSuite.Presentation.Views.Importer; using OSPSuite.UI.Controls; +using OSPSuite.UI.Extensions; using OSPSuite.UI.RepositoryItems; using OSPSuite.UI.Services; -using OSPSuite.Utility.Extensions; namespace OSPSuite.UI.Views.Importer { @@ -35,15 +34,20 @@ public partial class ColumnMappingControl : BaseUserControl, IColumnMappingContr new UxRepositoryItemButtonImage(ApplicationIcons.UnitInformation, Captions.UnitInformationDescription); private readonly RepositoryItemButtonEdit _disabledUnitButtonRepository = new UxRepositoryItemButtonImage(ApplicationIcons.EmptyIcon); - private readonly RepositoryItemButtonEdit _addButtonRepository = new UxRepositoryItemButtonImage(ApplicationIcons.Add, Captions.AddInformationDescription); + + private readonly RepositoryItemButtonEdit _addButtonRepository = + new UxRepositoryItemButtonImage(ApplicationIcons.Add, Captions.AddInformationDescription); private readonly RepositoryItemButtonEdit _lloqButtonRepository = new UxRepositoryItemButtonImage(ApplicationIcons.OutputInterval, Captions.LloqInformationDescription); + private readonly RepositoryItemButtonEdit _disabledLloqButtonRepository = new UxRepositoryItemButtonImage(ApplicationIcons.EmptyIcon); private readonly RepositoryItemButtonEdit _errorIconRepository = new UxRepositoryItemButtonImage(ApplicationIcons.Exit); private readonly RepositoryItemButtonEdit _errorUnitIconRepository = new UxRepositoryItemButtonImage(ApplicationIcons.MissingData); private readonly RepositoryItemButtonEdit _okIconRepository = new UxRepositoryItemButtonImage(ApplicationIcons.OK); private readonly RepositoryItemButtonEdit _emptyIconRepository = new UxRepositoryItemButtonImage(ApplicationIcons.EmptyIcon); + private readonly UxRepositoryItemImageComboBox _descriptionRepository; + private readonly UxRepositoryItemImageComboBox _nameRepository; public ColumnMappingControl(IImageListRetriever imageListRetriever) { @@ -52,13 +56,14 @@ public ColumnMappingControl(IImageListRetriever imageListRetriever) _gridViewBinder = new GridViewBinder(columnMappingGridView); columnMappingGridView.OptionsView.ShowGroupPanel = false; columnMappingGridView.OptionsMenu.EnableColumnMenu = false; - columnMappingGridView.CellValueChanged += (s, e) => _presenter.ValidateMapping(); + columnMappingGridView.MultiSelect = false; + columnMappingGridView.CellValueChanged += (o, e) => OnEvent(_presenter.ValidateMapping); columnMappingGridView.OptionsView.ShowButtonMode = ShowButtonModeEnum.ShowOnlyInEditor; - columnMappingGridView.OptionsBehavior.EditorShowMode = EditorShowMode.MouseUp; - columnMappingGridView.MouseDown += onMouseDown; - columnMappingGrid.ToolTipController = new ToolTipController(); - columnMappingGrid.ToolTipController.GetActiveObjectInfo += (o, e) => this.DoWithinExceptionHandler(() => onGetActiveObjectInfo(o, e)); + columnMappingGridView.OptionsBehavior.EditorShowMode = EditorShowMode.MouseDown; + columnMappingGridView.MouseDown += (o, e) => OnEvent(onMouseDown, o, e); + columnMappingGrid.ToolTipController = new ToolTipController().Initialize(imageListRetriever); + columnMappingGrid.ToolTipController.GetActiveObjectInfo += (o, e) => OnEvent(onGetActiveObjectInfo, o, e); var unitInformationTip = new SuperToolTip(); unitInformationTip.Items.Add(Captions.UnitInformationDescription); } @@ -68,33 +73,33 @@ public void AttachPresenter(IColumnMappingPresenter presenter) _presenter = presenter; } - private RepositoryItemImageComboBox valueRepository(ColumnMappingDTO model) + private RepositoryItem descriptionRepository(ColumnMappingDTO model) { - var repo = new RepositoryItemImageComboBox + var descriptionRepository = new UxRepositoryItemComboBox(columnMappingGridView) { AutoComplete = true, AllowNullInput = DefaultBoolean.True, CloseUpKey = new KeyShortcut(Keys.Enter) }; - fillComboBoxItems(repo, _presenter.GetAvailableOptionsFor(model)); - return repo; +// descriptionRepository.FillImageComboBoxRepositoryWith(_presenter.GetAvailableOptionsFor(model), x => x.IconIndex); + fillComboBoxItems(descriptionRepository, _presenter.GetAvailableOptionsFor(model)); + return descriptionRepository; } private RepositoryItemImageComboBox nameRepository(ColumnMappingDTO model) { - var repo = new RepositoryItemImageComboBox + var entry = new ColumnMappingOption() { - AllowNullInput = DefaultBoolean.True + Label = model.MappingName, + IconIndex = model.Icon, + Description = model.MappingName }; + var repo = new UxRepositoryItemImageComboBox(columnMappingGridView, _imageListRetriever) {AllowNullInput = DefaultBoolean.True}; + //repo.FillImageComboBoxRepositoryWith(new[] {entry}, x=>x.IconIndex); fillComboBoxItem ( - repo, - new ColumnMappingOption() - { - Label = model.MappingName, - IconIndex = model.Icon, - Description = model.MappingName - } + repo, + entry ); return repo; } @@ -104,7 +109,7 @@ public override void InitializeBinding() base.InitializeBinding(); _gridViewBinder.AddUnboundColumn() .WithCaption(UIConstants.EMPTY_COLUMN) - .WithShowButton(ShowButtonModeEnum.ShowOnlyInEditor) + .WithShowButton(ShowButtonModeEnum.ShowAlways) .WithRepository(invalidRepository) .WithFixedWidth(UIConstants.Size.BUTTON_WIDTH); @@ -115,31 +120,32 @@ public override void InitializeBinding() _gridViewBinder.AutoBind(x => x.Description) .WithCaption(Captions.Description) - .WithRepository(valueRepository) - .WithOnValueUpdating(onValueChanged) + .WithRepository(descriptionRepository) + .WithOnValueUpdated((o, e) => onValueChanged(o)) .WithShowButton(ShowButtonModeEnum.ShowAlways); _gridViewBinder.AddUnboundColumn() .WithCaption(UIConstants.EMPTY_COLUMN) - .WithShowButton(ShowButtonModeEnum.ShowOnlyInEditor) + .WithShowButton(ShowButtonModeEnum.ShowAlways) .WithRepository(removeRepository) .WithFixedWidth(UIConstants.Size.BUTTON_WIDTH); _gridViewBinder.AddUnboundColumn() .WithCaption(UIConstants.EMPTY_COLUMN) - .WithShowButton(ShowButtonModeEnum.ShowOnlyInEditor) + .WithShowButton(ShowButtonModeEnum.ShowAlways) .WithRepository(unitRepository) .WithFixedWidth(UIConstants.Size.BUTTON_WIDTH); _gridViewBinder.AddUnboundColumn() .WithCaption(UIConstants.EMPTY_COLUMN) - .WithShowButton(ShowButtonModeEnum.ShowOnlyInEditor) + .WithShowButton(ShowButtonModeEnum.ShowAlways) .WithRepository(lloqRepository) .WithFixedWidth(UIConstants.Size.BUTTON_WIDTH); _removeButtonRepository.ButtonClick += (o, e) => { columnMappingGridView.ActiveEditor.EditValue = ColumnMappingFormatter.Ignored(); + columnMappingGridView.CloseEditor(); _presenter.ClearRow(_gridViewBinder.FocusedElement); }; _unitButtonRepository.ButtonClick += (o, e) => _presenter.ChangeUnitsOnRow(_gridViewBinder.FocusedElement); @@ -153,7 +159,9 @@ public override void InitializeBinding() private RepositoryItem removeRepository(ColumnMappingDTO model) { - return model.Source == null || model.Source is IgnoredDataFormatParameter || model.Source is AddGroupByFormatParameter ? _disabledRemoveButtonRepository : _removeButtonRepository; + return model.Source == null || model.Source is IgnoredDataFormatParameter || model.Source is AddGroupByFormatParameter + ? _disabledRemoveButtonRepository + : _removeButtonRepository; } private RepositoryItem unitRepository(ColumnMappingDTO model) @@ -162,14 +170,17 @@ private RepositoryItem unitRepository(ColumnMappingDTO model) { return _unitButtonRepository; } + if (model.Source is AddGroupByFormatParameter) { if (string.IsNullOrEmpty(model.Source.ColumnName)) { return _disabledUnitButtonRepository; } + return _addButtonRepository; } + return _disabledUnitButtonRepository; } @@ -194,12 +205,14 @@ private RepositoryItem lloqRepository(ColumnMappingDTO model) { return _lloqButtonRepository; } + return _disabledLloqButtonRepository; } public void Rebind() - { - _gridViewBinder.Rebind(); + { + columnMappingGridView.RefreshData(); + // _gridViewBinder.Rebind(); } public void SetMappingSource(IList mappings) @@ -245,16 +258,13 @@ private void fillComboBoxItem(RepositoryItemImageComboBox editor, ColumnMappingO }); } - private void fillComboBoxItems(RepositoryItemImageComboBox editor, IEnumerable options) + private void fillComboBoxItems(RepositoryItemComboBox editor, IEnumerable options) { editor.Items.Clear(); editor.NullText = Captions.Importer.NoneEditorNullText; foreach (var option in options) { - editor.Items.Add(new ImageComboBoxItem(option.Description) - { - Description = option.Label, - }); + editor.Items.Add(new ComboBoxItem(option.Description)); } editor.KeyDown += clearSelectionOnDeleteForComboBoxEdit; @@ -265,9 +275,12 @@ private void fillComboBoxItems(RepositoryItemImageComboBox editor, IEnumerable e) + private void onValueChanged(ColumnMappingDTO model) { _presenter.SetDescriptionForRow(model); } From f82d15027a2cae0ec15e732b33d7668047e563e7 Mon Sep 17 00:00:00 2001 From: Michael Sevestre Date: Tue, 27 Oct 2020 15:51:58 -0400 Subject: [PATCH 2/3] WIP select on click: Some improvements --- src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs b/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs index 150ed04eb..d4e43c23b 100644 --- a/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs +++ b/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs @@ -46,8 +46,6 @@ public partial class ColumnMappingControl : BaseUserControl, IColumnMappingContr private readonly RepositoryItemButtonEdit _errorUnitIconRepository = new UxRepositoryItemButtonImage(ApplicationIcons.MissingData); private readonly RepositoryItemButtonEdit _okIconRepository = new UxRepositoryItemButtonImage(ApplicationIcons.OK); private readonly RepositoryItemButtonEdit _emptyIconRepository = new UxRepositoryItemButtonImage(ApplicationIcons.EmptyIcon); - private readonly UxRepositoryItemImageComboBox _descriptionRepository; - private readonly UxRepositoryItemImageComboBox _nameRepository; public ColumnMappingControl(IImageListRetriever imageListRetriever) { @@ -264,7 +262,7 @@ private void fillComboBoxItems(RepositoryItemComboBox editor, IEnumerable Date: Wed, 28 Oct 2020 11:30:39 -0400 Subject: [PATCH 3/3] Make it work with image combo box --- src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs b/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs index d4e43c23b..184c5b39f 100644 --- a/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs +++ b/src/OSPSuite.UI/Views/Importer/ColumnMappingControl.cs @@ -73,12 +73,13 @@ public void AttachPresenter(IColumnMappingPresenter presenter) private RepositoryItem descriptionRepository(ColumnMappingDTO model) { - var descriptionRepository = new UxRepositoryItemComboBox(columnMappingGridView) + var descriptionRepository = new UxRepositoryItemImageComboBox(columnMappingGridView, _imageListRetriever) { AutoComplete = true, AllowNullInput = DefaultBoolean.True, CloseUpKey = new KeyShortcut(Keys.Enter) }; + // descriptionRepository.FillComboBoxRepositoryWith(_presenter.GetAvailableOptionsFor(model)); // descriptionRepository.FillImageComboBoxRepositoryWith(_presenter.GetAvailableOptionsFor(model), x => x.IconIndex); fillComboBoxItems(descriptionRepository, _presenter.GetAvailableOptionsFor(model)); return descriptionRepository; @@ -256,13 +257,16 @@ private void fillComboBoxItem(RepositoryItemImageComboBox editor, ColumnMappingO }); } - private void fillComboBoxItems(RepositoryItemComboBox editor, IEnumerable options) + private void fillComboBoxItems(RepositoryItemImageComboBox editor, IEnumerable options) { editor.Items.Clear(); editor.NullText = Captions.Importer.NoneEditorNullText; foreach (var option in options) { - editor.Items.Add(new ComboBoxItem(option.Label)); + editor.Items.Add(new ImageComboBoxItem(option.Description) + { + Description = option.Label, + }); } editor.KeyDown += clearSelectionOnDeleteForComboBoxEdit;