Example #1
0
        public static void RegisterWidgetVariants(this IComponentsApplicationBuilder appBuilder)
        {
            IWidgetFactory widgetFactory = appBuilder.Services.GetService <IWidgetFactory>();

            widgetFactory.Register(WidgetVariants.SHOW_WIDGET, new WidgetVariant <ButtonWidgetMediator, ButtonWidgetPresenter>
            {
                Customisation = new ButtonWidgetCustomisation
                {
                    // Hind: Example of usage of strategy (delegate) in widget mediator
                    Title         = "Activate text widget in first container!",
                    ClickStrategy = () =>
                    {
                        // Hind: Manual widget build and activation, in most of cases would be easier to use IWidgetManagementService
                        WidgetInfo info = widgetFactory.Build(WidgetVariants.TEXT_FIRST);
                        IActivatable <string> activatable = (IActivatable <string>)info.Mediator;
                        activatable.Activate("FIRST_WIDGET_CONTAINER");
                    }
                }
            });

            var textVariant = new CustomisedWidgetVariant <TextWidgetMediator, TextWidgetCustomisation>();

            textVariant.Customisation.Text = "This text has been activated from runtime!";
            widgetFactory.Register(WidgetVariants.TEXT_FIRST, textVariant);

            widgetFactory.Register(WidgetVariants.RANDOM_UPDATER, new WidgetVariant <RandomUpdaterWidgetMediator>());

            widgetFactory.Register(WidgetVariants.COUNTER, new WidgetVariant <CounterWidgetMediator, CounterWidgetPresenter, CounterWidgetState>());

            widgetFactory.Register(WidgetVariants.LAYOUT, new WidgetVariant(typeof(ExampleLayoutWidget))
            {
                StateType = typeof(LayoutState)
            });
        }
Example #2
0
 internal Widget(IWidgetFactory myFactory, int id, string name, DateTime?manufactureDate = null)
 {
     Id               = id;
     Name             = name;
     ManufacturedDate = manufactureDate ?? DateTime.Now;
     Factory          = myFactory;
 }
Example #3
0
 internal Widget(IWidgetFactory myFactory, int id, string name, DateTime? manufactureDate = null)
 {
     Id = id;
     Name = name;
     ManufacturedDate = manufactureDate ?? DateTime.Now;
     Factory = myFactory;
 }
Example #4
0
        private async Task <TWidget> GetInstance <TWidget>(string widgetPath, UIMessage message,
                                                           IWidgetFactory factory = null)
            where TWidget : Widget
        {
            if (PoolingWidgets.ContainsKey(widgetPath))
            {
                var pool = PoolingWidgets[widgetPath];
                if (pool.Count > 0)
                {
                    var instance = pool.Pop();
                    return(instance as TWidget);
                }
            }

            if (factory == null)
            {
                factory = DefaultFactory;
            }

            TWidget widget;

            try { widget = (TWidget)await factory.CreateInstance(this, widgetPath, message); }
            catch (Exception e)
            {
                Her.Error(e);
                throw;
            }

            // mark widget factory
            FactoryLookup.Add(widget.ViewId, factory);

            return(widget);
        }
Example #5
0
        /// <summary>
        /// Advices the perspective to make the given <paramref name="dataView"/> visible at the <paramref name="viewPosition"/>.
        /// </summary>
        /// <param name="dataView">Data view to show</param>
        /// <param name="viewPosition">Target view position</param>
        public virtual void ShowView(IDataView dataView, EViewPosition viewPosition)
        {
            if (dataView == null)
            {
                return;
            }

            try {
                // Notify data view to init
                dataView.Init();

                // Set up new view
                IWidgetFactory widgetFactory = FactoryProvider.Instance.GetWidgetFactory();
                dataView.WidgetFactory = widgetFactory;

                // Make view visible
                OnShowDataView(dataView, viewPosition);

                // Update internal state and dispatch events
                ActiveDataViews.Add(dataView);
                PerspectiveEventManager.Dispatch(lstnr => lstnr.OnWorkbenchPartOpened(dataView), OnDispatchWorkbenchEventException);
            } catch (Exception ex) {
                _log.Error($"Error on showing data view '{dataView}' by perspective '{this}'.", ex);
            }
        }
Example #6
0
        public static void RegisterFactory(Type type, IWidgetFactory factory)
        {
            if (FactoryLookup.ContainsKey(type))
            {
                Debug.LogErrorFormat("Factory already registered for type: {0}.", type);
            }

            FactoryLookup[type] = factory;
        }
Example #7
0
        public LayoutEngine(IWidgetFactory factory)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }

            this.widgetFactory = factory;
        }
Example #8
0
        public WidgetClient(WidgetCreatorName widgetCreaterName)
        {
            AbstractFactoryAgent objAbstractFactoryAgent = new AbstractFactoryAgent(widgetCreaterName);

            widgetFactoryObj = objAbstractFactoryAgent.GetFactoryObject();
            Window           = widgetFactoryObj.CreateWindow();
            Scrollbar        = widgetFactoryObj.CreateScrollBar();
            Toolbar          = widgetFactoryObj.CreateToolBar();
            Button           = widgetFactoryObj.CreateButtons();
        }
Example #9
0
        public LiquidWidgetFinder()
        {
            var container = GetContainer();

            _templateProvider = container.GetInstance <ITemplateProvider>();
            _widgetFactory    = container.GetInstance <IWidgetFactory>();
            _dataDecorators   = container.GetInstance <List <LiquidDataDecorator> >().OrderBy(x => x.LevelToReachRealWrappe)
                                .ToList();
            _widgetDataService = container.GetInstance <IWidgetDataService>();
        }
        public WidgetManagementService(
            IWidgetStore store,
            IWidgetFactory factory,
            IMessageBus messageBus,
            ILogger logger)
        {
            this.store      = store ?? throw new ArgumentNullException(nameof(store));
            this.factory    = factory ?? throw new ArgumentNullException(nameof(factory));
            this.messageBus = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
            this.logger     = logger;

            RegisterWithMessageBus();
        }
Example #11
0
        private void ConstructorCore(IWebDriver webdriver, IWidgetFactory widgetFactory, int implicitWaitSeconds)
        {
            if (webdriver == null)
            {
                throw new ArgumentNullException(nameof(webdriver));
            }

            _driver    = webdriver;
            JsExecutor = (IJavaScriptExecutor)_driver;
            SetImplicitWait(implicitWaitSeconds);
            WidgetFactory = widgetFactory;
            By.SetQxWebDriver(this);
        }
Example #12
0
        /// <inheritdoc />
        public override void Initialize(IGridPanel gridComposite, IWidgetFactory widgetFactory)
        {
            Title       = Messages.NewWizardOpeningPage_Title;
            Description = Messages.NewWizardOpeningPage_Description;

            ITreeViewer treeViewer = UIFactory.NewWidget <ITreeViewer>(gridComposite);

            gridComposite.AddWidget(treeViewer);

            treeViewer.ContentProvider = new NewWizardTreeContentProvider();
            treeViewer.LabelProvider   = new NewWizardTreeLabelProvider();
            treeViewer.Input           = NewWizardRegistry.Instance.Contributions;
            treeViewer.Update();
            treeViewer.SelectionChanged += OnSelectionChanged;
        }
 public WidgetContainerService(List <IBaseBeforeAddingEntityLogic> baseBeforeAddingEntityLogics,
                               List <BaseAfterAddingEntityLogic> baseAfterAddingEntityLogics,
                               List <IBaseAfterUpdatingEntityLogic> baseAfterUpdateEntityLogics,
                               List <IBaseBeforeUpdatingEntityLogic> baseBeforeUpdateEntityLogics,
                               List <IBaseBeforeDeleteEntityLogic> baseBeforeDeleteEntityLogics,
                               List <BaseAfterDeleteEntityLogic> baseAfterDeleteEntityLogics, IIdentityManager identityManager,
                               IRestrictedItemAccessManager accessManager, IWidgetContainerDataService widgetContainerDataSrv, IWidgetDataService widgetDataService, IWidgetFactory widgetFactory)
     : base(
         baseBeforeAddingEntityLogics, baseAfterAddingEntityLogics, baseAfterUpdateEntityLogics,
         baseBeforeUpdateEntityLogics, baseBeforeDeleteEntityLogics, baseAfterDeleteEntityLogics, identityManager,
         accessManager, widgetContainerDataSrv)
 {
     _widgetContainerDataSrv = widgetContainerDataSrv;
     _widgetDataService      = widgetDataService;
     _widgetFactory          = widgetFactory;
 }
Example #14
0
        public MainViewModel(
            IWidgetFactory widgetFactory,
            IWidgetRegistry widgetRegistry,
            ILogger logger,
            INavigationManager navigationManager,
            IEventAggregator eventAggregator,
            ISettingsService settingsService,
            IDialogService dialogService,
            ModulesApiClient modulesApiClient,
            ModuleConnectionsApiClient connectionsApiClient,
            ModulesSerializer modulesSerializer)
        {
            _widgetRegistry       = widgetRegistry;
            _logger               = logger;
            _navigationManager    = navigationManager;
            _eventAggregator      = eventAggregator;
            _settingsService      = settingsService;
            _dialogService        = dialogService;
            _modulesApiClient     = modulesApiClient;
            _connectionsApiClient = connectionsApiClient;
            _modulesSerializer    = modulesSerializer;

            _widgets = new ObservableCollection <WidgetViewModel>();
            _widgets.CollectionChanged += OnWidgetsCollectionChanged;
            _connections = new ObservableCollection <ConnectionViewModel>();
            _connections.CollectionChanged += OnConnectionsCollectionChanged;

            _savingBuffer = new List <WidgetViewModel>();

            WidgetFactory = widgetFactory;

            RefreshCommand = new DelegateCommand(async() => await LoadDataAsync(), () => !IsBusy);
            AddCommandBinding(CustomApplicationCommands.Refresh, RefreshCommand);

            DeleteCommand = new DelegateCommand(Delete, () => !IsBusy && Widgets.Any(w => w.IsSelected));
            AddCommandBinding(CustomApplicationCommands.Delete, DeleteCommand);

            ImportFileCommand = new DelegateCommand(ImportFile, () => !IsBusy);
            AddCommandBinding(CustomApplicationCommands.Import, ImportFileCommand);

            ExportFileCommand = new DelegateCommand(ExportFile, () => !IsBusy);
            AddCommandBinding(CustomApplicationCommands.Export, ExportFileCommand);
        }
Example #15
0
        public AbstractFactoryAgent(WidgetCreatorName creator)
        {
            switch (creator)
            {
            case WidgetCreatorName.Apple:
                factoryObj = new AppleWidgetFactory();
                break;

            case WidgetCreatorName.Google:
                factoryObj = new GoogleWidgetFactory();
                break;

            case WidgetCreatorName.Microsoft:
                factoryObj = new MicrosoftWidgetFactory();
                break;

            default:
                factoryObj = new AppleWidgetFactory();
                break;
            }
        }
Example #16
0
        public async Task <ulong> PushAsync <TWidget>(string widgetName, UIMessage message,
                                                      IWidgetFactory factory = null)
            where TWidget : Widget
        {
            var instance = await GetInstance <TWidget>(widgetName, message, factory);

            var parent = LayerLookup[instance.Layer];

            instance.transform.SetParent(parent.transform, false);

            switch (instance.Layer)
            {
            case UILayer.Popup:
                Popups.Add(instance.ViewId);
                break;
            }

            if (StackedWindows.Count > 0)
            {
                var prevWidget = StackedWindows.Peek();

                if (prevWidget != null)
                {
                    await prevWidget.OnFreeze();

                    // Window will overlay previous windows.
                    if (instance.Layer == UILayer.Window && WindowsInDisplay.Contains(prevWidget.ViewId))
                    {
                        WindowsInDisplay.Remove(prevWidget.ViewId);
                    }
                }
            }

            await instance.OnShow();

            StackedWindows.Push(instance);
            WindowsInDisplay.Add(instance.ViewId);

            return(instance.ViewId);
        }
Example #17
0
 public OldWidgetService(ApplicationContext context, IWidgetFactory widgetFactory)
 {
     _context       = context;
     _widgetFactory = widgetFactory;
 }
Example #18
0
 public abstract object CreateWidgetControl(IWidgetFactory factory);
Example #19
0
 public void RegisterDefaultFactory(IWidgetFactory factory)
 {
     DefaultFactory = factory ?? throw new ArgumentNullException();
 }
 public UpdatedWidgetService(IWidgetRepository widgetRepository, IWidgetFactory widgetFactory)
 {
     _widgetRepository = widgetRepository;
     _widgetFactory    = widgetFactory;
 }
 public ClassThatTakesConstructorArguments(IWidgetFactory foo, string name)
 {
 }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QxWebDriver" /> class.
 /// </summary>
 /// <param name="webdriver">The webdriver to wrap.</param>
 /// <param name="widgetFactory">The widget factory to use.</param>
 /// <param name="implicitWaitSeconds">The implicit wait duration in seconds.</param>
 public QxWebDriver(IWebDriver webdriver, IWidgetFactory widgetFactory, int implicitWaitSeconds)
 {
     ConstructorCore(webdriver, widgetFactory, implicitWaitSeconds);
 }
Example #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QxWebDriver" /> class.
        /// </summary>
        /// <param name="browser">The browser of the webdriver to wrap.</param>
        /// <param name="options">The colection of options specific to a browser driver.</param>
        /// <param name="widgetFactory">The widget factory to use.</param>
        /// <param name="implicitWaitSeconds">The implicit wait duration in seconds.</param>
        public QxWebDriver(Browser browser, object options, IWidgetFactory widgetFactory, int implicitWaitSeconds)
        {
            var webdriver = GetWrappedDriver(browser, options);

            ConstructorCore(webdriver, widgetFactory, implicitWaitSeconds);
        }
Example #24
0
 /// <inheritdoc />
 public abstract void Initialize(IGridPanel gridComposite, IWidgetFactory widgetFactory);
 public override object CreateWidgetControl(IWidgetFactory factory)
 {
     return(factory.CreateCalendarWidget());
 }
Example #26
0
 public WidgetsManager(IWidgetFactory widgetApplication, IOptions <WidgetOptions> options)
 {
     _widgetApplication = widgetApplication;
     _options           = options.Value;
 }
Example #27
0
 public void Render(IWidgetFactory widgetFactory)
 {
     widgetFactory.CreateButton().Render();
     widgetFactory.CreateTextBox().Render();
 }
Example #28
0
 public override object CreateWidgetControl(IWidgetFactory factory)
 {
     return factory.CreateTextBoxWidget();
 }
Example #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="QxWebDriver"/> class.
        /// </summary>
        /// <param name="browser">The browser of the webdriver to wrap.</param>
        /// <param name="options">The colection of options specific to a browser driver.</param>
        /// <param name="widgetFactory">The widget factory to use.</param>
        public QxWebDriver(Browser browser, object options, IWidgetFactory widgetFactory)
        {
            var webdriver = GetWrappedDriver(browser, options);

            ConstructorCore(webdriver, widgetFactory, 4);
        }
Example #30
0
 public override object CreateWidgetControl(IWidgetFactory factory)
 {
     return factory.CreateRadioWidget(TrueLabel, FalseLabel);
 }
Example #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QxWebDriver"/> class.
 /// </summary>
 /// <param name="webdriver">The webdriver to wrap.</param>
 /// <param name="widgetFactory">The widget factory to use.</param>
 public QxWebDriver(IWebDriver webdriver, IWidgetFactory widgetFactory)
 {
     ConstructorCore(webdriver, widgetFactory, 4);
 }
 public override object CreateWidgetControl(IWidgetFactory factory)
 {
     return(factory.CreateRadioWidget(TrueLabel, FalseLabel));
 }
 public override object CreateWidgetControl(IWidgetFactory factory)
 {
     return factory.CreateCalendarWidget();
 }
Example #34
0
 public WidgetsManager(IWidgetFactory widgetApplication, WidgetOptions options)
 {
     _widgetApplication = widgetApplication;
     _options           = options;
 }
Example #35
0
 public ClassThatTakesConstructorArguments(IWidgetFactory foo, string name)
 {
 }
Example #36
0
 public async Task <ulong> PushAsync(string widgetName, UIMessage message,
                                     IWidgetFactory factory = null)
 {
     return(await PushAsync <Widget>(widgetName, message, factory));
 }