public void OpenMultipleSelectionJournal <TEntity>(IRepresentationModel model, Action <TEntity[]> onSelectedAction, Action <ITdiTab> openTabAction)
            where TEntity : class, IDomainObject
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (onSelectedAction == null)
            {
                throw new ArgumentNullException(nameof(onSelectedAction));
            }

            if (openTabAction == null)
            {
                throw new ArgumentNullException(nameof(openTabAction));
            }

            if (model.EntityType != typeof(TEntity))
            {
                throw new InvalidOperationException($"Тип в модели представления \"{nameof(model)}\" должен совпадать с типом сущности \"{typeof(TEntity).Name}\" ");
            }

            var journal = journalFactory.CreateJournal(model);

            journal.Mode            = JournalSelectMode.Multiple;
            journal.ObjectSelected += (sender, e) => {
                TEntity[] selectedEntities = e.Selected.OfType <TEntity>().ToArray();
                onSelectedAction.Invoke(selectedEntities);
            };
            openTabAction.Invoke(journal);
        }
 public ReferenceRepresentation(IRepresentationModel representation)
 {
     this.Build();
     RepresentationModel = representation;
     InitializePermissionValidator();
     ConfigureDlg();
 }
 public EntityRepresentationSelectorAdapter(Type entityType, IRepresentationModel model, string tabName = null, bool multipleSelect = false)
 {
     this.entityType     = entityType ?? throw new ArgumentNullException(nameof(entityType));
     this.model          = model ?? throw new ArgumentNullException(nameof(model));
     this.multipleSelect = multipleSelect;
     SetTabName(tabName);
     Configure();
 }
Exemple #4
0
 protected RepresentationButtonBase(IJournalDialog dialog, IRepresentationModel representationModel, string title, string iconStockId = null)
 {
     button = iconStockId == null ? new Button() : new Button(iconStockId);
     this.RepresentationModel = representationModel;
     this.dialog     = dialog;
     button.Label    = Title = title;
     button.Clicked += Button_Clicked;
 }
Exemple #5
0
 public PermissionControlledEditButton(
     IJournalDialog dialog,
     IRepresentationModel representationModel,
     IPermissionResult permission,
     bool customEdit = false) : base(dialog, representationModel)
 {
     this.permission = permission;
     _customEdit     = customEdit;
 }
 public EntityRepresentationSelectorAdapter(IRepresentationModel model, string tabName = null, bool multipleSelect = false) : base()
 {
     this.model          = model ?? throw new ArgumentNullException(nameof(model));
     this.multipleSelect = multipleSelect;
     if (model.EntityType == null)
     {
         throw new ArgumentException("Модель должна иметь информацию о загружаемой сущности");
     }
     TabName         = tabName;
     this.entityType = model.EntityType;
     SetTabName(tabName);
     Configure();
 }
        public PermissionControlledRepresentationJournal(IRepresentationModel representationModel, Buttons buttons = Buttons.All) : base(representationModel)
        {
            if (RepresentationModel.EntityType != null)
            {
                UpdateUserEntityPermission();
                if (!permissionResult.CanRead)
                {
                    var message = PermissionsSettings.GetEntityReadValidateResult(RepresentationModel.EntityType);
                    MessageDialogHelper.RunErrorDialog(message);
                    FailInitialize = true;
                }
            }

            this.buttons = buttons;
            ConfigureActionButtons();
        }
Exemple #8
0
 public PermissionControlledDeleteButton(IJournalDialog dialog, IRepresentationModel representationModel, IPermissionResult permission) : base(dialog, representationModel)
 {
     this.permission = permission;
 }
 public ReferenceRepresentation(IRepresentationModel representation, string tilte) : this(representation)
 {
     TabName = tilte;
 }
Exemple #10
0
 public RepresentationEditButton(IJournalDialog dialog, IRepresentationModel representationModel)
     : base(dialog, representationModel, "Изменить", "gtk-edit")
 {
 }
Exemple #11
0
 public RepresentationAddButton(IJournalDialog dialog, IRepresentationModel representationModel)
     : base(dialog, representationModel, "Добавить", "gtk-add")
 {
 }
 public static string GenerateHashName(IRepresentationModel model)
 {
     return(GenerateHashName(model.GetType()));
 }
 public RepresentationJournalDialog CreateJournal(IRepresentationModel model)
 {
     return(new PermissionControlledRepresentationJournal(model));
 }
Exemple #14
0
 public RepresentationDeleteButton(IJournalDialog dialog, IRepresentationModel representationModel)
     : base(dialog, representationModel, "Удалить", "gtk-remove")
 {
 }
Exemple #15
0
 public ReferenceRepresentation(IRepresentationModel representation)
 {
     this.Build();
     RepresentationModel = representation;
     ConfigureDlg();
 }