Beispiel #1
0
        public void SetTo(IPipeline pipeline, IPipelineUseCase useCase)
        {
            _useCase = useCase;

            _pipeline = pipeline;
            if (_pipeline != null)
            {
                _pipeline.ClearAllInjections();
            }

            //clear the diagram
            flpPipelineDiagram.Controls.Clear();

            pipelineSmiley.Reset();

            try
            {
                //if there is a pipeline
                if (_pipeline != null)
                {
                    try
                    {
                        _pipelineFactory = new DataFlowPipelineEngineFactory(_useCase, _pipeline);

                        //create it
                        IDataFlowPipelineEngine pipelineInstance = _pipelineFactory.Create(pipeline, new ThrowImmediatelyDataLoadEventListener());

                        //initialize it (unless it is design time)
                        if (!_useCase.IsDesignTime)
                        {
                            pipelineInstance.Initialize(_useCase.GetInitializationObjects().ToArray());
                        }
                    }
                    catch (Exception ex)
                    {
                        pipelineSmiley.Fatal(ex);
                    }

                    //There is a pipeline set but we might have been unable to fully realize it so setup stuff based on PipelineComponents

                    //was there an explicit instance?
                    if (_useCase.ExplicitSource != null)
                    {
                        AddExplicit(_useCase.ExplicitSource);//if so add it
                    }
                    else
                    //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken?
                    if (pipeline.SourcePipelineComponent_ID != null)
                    {
                        AddPipelineComponent((int)pipeline.SourcePipelineComponent_ID, DataFlowComponentVisualisation.Role.Source, pipeline.Repository);    //add the possibly broken PipelineComponent to the diagram
                    }
                    else
                    {
                        AddBlankComponent(DataFlowComponentVisualisation.Role.Source);    //the user hasn't put one in yet
                    }
                    foreach (var middleComponent in pipeline.PipelineComponents.Where(c => c.ID != pipeline.SourcePipelineComponent_ID && c.ID != pipeline.DestinationPipelineComponent_ID).OrderBy(comp => comp.Order))
                    {
                        AddPipelineComponent(middleComponent, DataFlowComponentVisualisation.Role.Middle);//add the possibly broken PipelineComponent to the diagram
                    }
                    //was there an explicit instance?
                    if (_useCase.ExplicitDestination != null)
                    {
                        AddDividerIfReorderingAvailable();
                        AddExplicit(_useCase.ExplicitDestination);//if so add it
                    }
                    else
                    //there wasn't an explicit one so there was a PipelineComponent maybe? albiet one that might be broken?
                    if (pipeline.DestinationPipelineComponent_ID != null)
                    {
                        AddPipelineComponent((int)pipeline.DestinationPipelineComponent_ID, DataFlowComponentVisualisation.Role.Destination, pipeline.Repository);    //add the possibly broken PipelineComponent to the diagram
                    }
                    else
                    {
                        AddDividerIfReorderingAvailable();
                        AddBlankComponent(DataFlowComponentVisualisation.Role.Destination);    //the user hasn't put one in yet
                    }


                    return;
                }


                //Fallback
                //user has not picked a pipeline yet, show him the shell (factory)
                //factory has no source, add empty source
                if (_useCase.ExplicitSource == null)
                {
                    AddBlankComponent(DataFlowComponentVisualisation.Role.Source);
                }
                else
                {
                    AddExplicit(_useCase.ExplicitSource);
                }


                //factory has no source, add empty source
                if (_useCase.ExplicitDestination == null)
                {
                    AddBlankComponent(DataFlowComponentVisualisation.Role.Destination);
                }
                else
                {
                    AddExplicit(_useCase.ExplicitDestination);
                }
            }
            finally
            {
                Invalidate();
            }
        }
        private void CreateLine(IArgumentHost parent, IArgument argument, RequiredPropertyInfo required, float maxArgNameWidth)
        {
            Label name = new Label();

            HelpIcon helpIcon = new HelpIcon();

            helpIcon.SetHelpText(GetSystemTypeName(argument.GetSystemType()) ?? "Unrecognised Type:" + argument.Type, required.Demand.Description);
            helpIcon.Dock = DockStyle.Right;

            string spaceSeparatedArgumentName = UsefulStuff.PascalCaseStringToHumanReadable(argument.Name);

            name.Height    = helpIcon.Height;
            name.Text      = spaceSeparatedArgumentName;
            name.TextAlign = ContentAlignment.MiddleLeft;
            name.Dock      = DockStyle.Left;
            name.Width     = (int)maxArgNameWidth + 3 /*padding*/;

            RAGSmiley ragSmiley = new RAGSmiley();

            if (required.Demand.Mandatory && string.IsNullOrWhiteSpace(argument.Value))
            {
                ragSmiley.Fatal(new Exception("Property " + argument.Name + " is Mandatory"));
            }

            var args = new ArgumentValueUIArgs();

            args.Parent      = parent;
            args.Type        = argument.GetSystemType();
            args.ContextText = required.Demand.ContextText;

            try
            {
                args.InitialValue = argument.GetValueAsSystemType();
            }
            catch (Exception e)
            {
                //add the text value value and report the error
                if (_valueUisFactory.CanHandleInvalidStringData(args.Type))
                {
                    args.InitialValue = argument.Value;
                }
                else
                {
                    args.InitialValue = null;
                }

                ragSmiley.Fatal(e);
            }


            args.Required            = required;
            args.CatalogueRepository = (ICatalogueRepository)argument.Repository;
            args.Setter = (v) =>
            {
                ragSmiley.Reset();

                try
                {
                    argument.SetValue(v);
                    argument.SaveToDatabase();

                    argument.GetValueAsSystemType();

                    if (required.Demand.Mandatory && (v == null || string.IsNullOrWhiteSpace(v.ToString())))
                    {
                        ragSmiley.Fatal(new Exception("Property " + argument.Name + " is Mandatory"));
                    }
                }
                catch (Exception ex)
                {
                    ragSmiley.OnCheckPerformed(new CheckEventArgs("Failed to set property properly", CheckResult.Fail, ex));
                }
            };
            args.Fatal = ragSmiley.Fatal;

            var valueui = (Control)_valueUisFactory.Create(_activator, args);

            valueui.Dock = DockStyle.Fill;

            Panel p = new Panel();

            p.Height = Math.Max(Math.Max(lblClassName.Height, helpIcon.Height), valueui.Height);
            p.Dock   = DockStyle.Top;

            name.Location = new Point(0, 0);
            p.Controls.Add(name);

            helpIcon.Left = name.Right;
            p.Controls.Add(helpIcon);

            ragSmiley.Dock = DockStyle.Right;
            p.Controls.Add(ragSmiley);
            p.Controls.Add(valueui);

            name.Height = p.Height;

            Label hr = new Label();

            hr.AutoSize    = false;
            hr.BorderStyle = BorderStyle.FixedSingle;
            hr.Height      = 1;
            hr.Dock        = DockStyle.Bottom;
            p.Controls.Add(hr);

            valueui.BringToFront();
            pArguments.Controls.Add(p);
        }
Beispiel #3
0
        private void CreateLine(IArgumentHost parent, IArgument argument, RequiredPropertyInfo required)
        {
            Label name = new Label();

            HelpIcon helpIcon = new HelpIcon();

            helpIcon.SetHelpText(GetSystemTypeName(argument.GetSystemType()) ?? "Unrecognised Type:" + argument.Type, required.Demand.Description);
            helpIcon.Anchor = AnchorStyles.Top | AnchorStyles.Left;

            string spaceSeparatedArgumentName = UsefulStuff.PascalCaseStringToHumanReadable(argument.Name);

            name.Height    = helpIcon.Height;
            name.Text      = spaceSeparatedArgumentName;
            name.TextAlign = ContentAlignment.MiddleLeft;
            name.AutoSize  = true;
            name.Anchor    = AnchorStyles.Top | AnchorStyles.Left;

            RAGSmiley ragSmiley = new RAGSmiley();

            if (required.Demand.Mandatory && string.IsNullOrWhiteSpace(argument.Value))
            {
                ragSmiley.Fatal(new Exception("Property " + argument.Name + " is Mandatory"));
            }

            var args = new ArgumentValueUIArgs();

            args.Parent = parent;
            args.Type   = argument.GetSystemType();

            try
            {
                args.InitialValue = argument.GetValueAsSystemType();
            }
            catch (Exception e)
            {
                //add the text value value and report the error
                if (_valueUisFactory.CanHandleInvalidStringData(args.Type))
                {
                    args.InitialValue = argument.Value;
                }
                else
                {
                    args.InitialValue = null;
                }

                ragSmiley.Fatal(e);
            }


            args.Required            = required;
            args.CatalogueRepository = (ICatalogueRepository)argument.Repository;
            args.Setter = (v) =>
            {
                ragSmiley.Reset();

                try
                {
                    argument.SetValue(v);
                    argument.SaveToDatabase();

                    argument.GetValueAsSystemType();

                    if (required.Demand.Mandatory && (v == null || string.IsNullOrWhiteSpace(v.ToString())))
                    {
                        ragSmiley.Fatal(new Exception("Property " + argument.Name + " is Mandatory"));
                    }
                }
                catch (Exception ex)
                {
                    ragSmiley.OnCheckPerformed(new CheckEventArgs("Failed to set property properly", CheckResult.Fail, ex));
                }
            };
            args.Fatal = ragSmiley.Fatal;

            var valueui = (Control)_valueUisFactory.Create(args);

            valueui.Anchor = name.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            _valueUIs.Add(valueui);

            Panel p = new Panel();

            p.Height      = Math.Max(Math.Max(lblClassName.Height, helpIcon.Height), valueui.Height);
            p.Width       = pArguments.ClientRectangle.Width;
            p.Anchor      = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
            p.BorderStyle = BorderStyle.FixedSingle;
            p.Location    = new Point(0, _currentY);
            _currentY    += p.Height;

            name.Location = new Point(0, 0);
            p.Controls.Add(name);

            helpIcon.Left = name.Right;
            p.Controls.Add(helpIcon);

            ragSmiley.Left   = p.Width - ragSmiley.Width;
            ragSmiley.Anchor = AnchorStyles.Right | AnchorStyles.Top;
            p.Controls.Add(ragSmiley);

            valueui.Left    = helpIcon.Right;
            valueui.Width   = p.Width - (helpIcon.Right + ragSmiley.Left);
            _maxValueUILeft = Math.Max(_maxValueUILeft, valueui.Left);
            p.Controls.Add(valueui);
            p.MinimumSize = new Size(ragSmiley.Right, p.Height);

            name.Height = p.Height;

            pArguments.Controls.Add(p);
        }