Beispiel #1
0
        private void AddAdvertisedComponent(DragEventArgs e, DividerLineControl divider)
        {
            var advert = GetAdvertisedObjectFromDragOperation(e);

            if (
                //if user is trying to add a source
                advert.GetRole() == DataFlowComponentVisualisation.Role.Source
                //and there is already an explicit source or a configured one
                && (_useCase.ExplicitSource != null || _pipeline.SourcePipelineComponent_ID != null))
            {
                MessageBox.Show("There is already a source in this pipeline");
                return;
            }

            if (
                //if user is trying to add a destination
                advert.GetRole() == DataFlowComponentVisualisation.Role.Destination
                //and there is already an explicit destination or a configured one
                && (_useCase.ExplicitDestination != null || _pipeline.DestinationPipelineComponent_ID != null))
            {
                MessageBox.Show("There is already a destination in this pipeline");
                return;
            }

            Type underlyingComponentType = advert.GetComponentType();

            //add the component to the pipeline
            var repository = (ICatalogueRepository)_pipeline.Repository;
            var newcomp    = new PipelineComponent(repository, _pipeline, underlyingComponentType, -999, advert.ToString())
            {
                Order = GetOrderMakingSpaceIfNessesary(null, divider)
            };


            newcomp.CreateArgumentsForClassIfNotExists(underlyingComponentType);

            newcomp.SaveToDatabase();

            if (advert.GetRole() == DataFlowComponentVisualisation.Role.Source)
            {
                _pipeline.SourcePipelineComponent_ID = newcomp.ID;
                _pipeline.SaveToDatabase();
            }

            if (advert.GetRole() == DataFlowComponentVisualisation.Role.Destination)
            {
                _pipeline.DestinationPipelineComponent_ID = newcomp.ID;
                _pipeline.SaveToDatabase();
            }

            RefreshUIFromDatabase();


            var viz = flpPipelineDiagram.Controls.OfType <PipelineComponentVisualisation>().Single(v => Equals(v.PipelineComponent, newcomp));

            component_Selected(viz, newcomp);
        }
Beispiel #2
0
        private void AddDividerIfReorderingAvailable()
        {
            if (!AllowReOrdering)
            {
                return;
            }

            DividerLineControl divider = new DividerLineControl(dividerLine_shouldAllowDrop);

            divider.DragDrop += divider_DragDrop;
            flpPipelineDiagram.Controls.Add(divider);
        }
Beispiel #3
0
        private int GetOrderMakingSpaceIfNessesary(PipelineComponentVisualisation beingReorderedIfAny, DividerLineControl divider)
        {
            int newOrder = 0;
            int toReturn = 0;

            //for each component in the diagram
            for (int i = 0; i < flpPipelineDiagram.Controls.Count; i++)
            {
                var controlAtIndex = flpPipelineDiagram.Controls[i];
                var pipelineComponentVisAtIndex = flpPipelineDiagram.Controls[i] as PipelineComponentVisualisation;

                //do not set the order on the thing being reordered! note that this is null in the case of newly dragged in controls so will never execute continue for new drop operations
                if (controlAtIndex == beingReorderedIfAny)
                {
                    continue;
                }

                //found pipeline component
                if (pipelineComponentVisAtIndex != null)
                {
                    //increment the order
                    pipelineComponentVisAtIndex.PipelineComponent.Order = newOrder;
                    pipelineComponentVisAtIndex.PipelineComponent.SaveToDatabase();
                    newOrder++;
                }

                //found the divider this is the order we are supposed to be inserting / reordering into
                if (controlAtIndex == divider)
                {
                    //found divider  so mark this as the insertion order point
                    toReturn = newOrder;
                    newOrder++;
                }
            }

            return(toReturn);
        }
Beispiel #4
0
 private void HandleReorder(PipelineComponentVisualisation forReorder, DividerLineControl divider)
 {
     forReorder.PipelineComponent.Order = GetOrderMakingSpaceIfNessesary(forReorder, divider);
     forReorder.PipelineComponent.SaveToDatabase();
 }