예제 #1
0
 public static void Execute(UMLDiagram owningDiagram, MonoUML.DI.Point position)
 {
     ExpertCoder.Uml2.Actor actorModel = (ExpertCoder.Uml2.Actor)MonoUML.Widgets.Helper.CreateUmlElement ("Actor");
     UMLActor actor = UMLActor.CreateNew (owningDiagram, actorModel);
     actor.Move (position.X, position.Y);
     owningDiagram.AddNewClassifier(actor, actorModel);
 }
예제 #2
0
 public static void Execute(UMLDiagram owningDiagram, MonoUML.DI.Point position)
 {
     ExpertCoder.Uml2.Class classModel = (ExpertCoder.Uml2.Class)MonoUML.Widgets.Helper.CreateUmlElement ("Class");
     UMLClass cls = UMLClass.CreateNew (owningDiagram, classModel);
     cls.Move (position.X, position.Y);
     owningDiagram.AddNewClassifier(cls, classModel);
 }
        public static UMLInstanceSpecification CreateNew(
			UMLDiagram ownerDiagram,
			UML.InstanceSpecification iSpecModel)
        {
            DI.GraphNode isGN = UMLBox.CreateNewGraphNode(ownerDiagram, iSpecModel);
            return new UMLInstanceSpecification (ownerDiagram, isGN);
        }
예제 #4
0
        public static UMLClass CreateNew(
			UMLDiagram ownerDiagram,
			UML.Class clsModel )
        {
            // creates the graphical representation of the new Class
            DI.GraphNode classifierGN = new DI.GraphNode ();
            //    model bridge to the UML model element (Class)
            Uml2SemanticModelBridge bridge = new Uml2SemanticModelBridge ();
            bridge.Element = clsModel;
            classifierGN.SemanticModel = bridge;
            // graphical representation of the property "Name"
            DI.GraphNode nameGN = new DI.GraphNode ();
            //    graphical properties
            nameGN.Position.X = 4D;
            nameGN.Position.Y = 6D;
            nameGN.Property[DI.StandardProperty.FontFamily] = "Verdana";
            nameGN.Property[DI.StandardProperty.FontSize] = "10";
            //    model bridge to the property
            DI.SimpleSemanticModelElement nameBridge = new DI.SimpleSemanticModelElement ();
            nameBridge.TypeInfo = "NameCompartment";
            nameGN.SemanticModel = nameBridge;
            // adds the name GN to the Use Case GN
            classifierGN.Contained.Add (nameGN);
            nameGN.Container = classifierGN;
            // adds the classifier to the diagram
            ownerDiagram.DIDiagram.Contained.Add (classifierGN);
            classifierGN.Container = ownerDiagram.DIDiagram;
            return new UMLClass (ownerDiagram, classifierGN);
        }
예제 #5
0
 public UMLBox(UMLDiagram ownerDiagram, DI.GraphNode graphNode)
     : base(ownerDiagram, graphNode)
 {
     _outerBox = new CanvasRect (ChildrensRoot);
     _outerBox.X1 = _outerBox.Y1 = 0;
     _outerBox.X2 = Width;
     _outerBox.Y2 = Height;
     _outerBox.FillColor = DEFAULT_FILL_COLOR;
     _outerBox.OutlineColor = DEFAULT_OUTLINE_COLOR;
     Width = graphNode.Size.Width;
     Height = graphNode.Size.Height;
     // gets the corresponding model element
     Uml2SemanticModelBridge bridge = (Uml2SemanticModelBridge) graphNode.SemanticModel;
     _modelElement = (UML.NamedElement) bridge.Element;
     DI.GraphElement nestedDiagElem;
     DI.SimpleSemanticModelElement nestedBridge;
     // looks for the Name compartment
     foreach (DI.DiagramElement elem in GraphNode.Contained)
     {
         nestedDiagElem = elem as DI.GraphElement;
         if (nestedDiagElem != null)
         {
             nestedBridge = nestedDiagElem.SemanticModel as DI.SimpleSemanticModelElement;
             if (nestedBridge.TypeInfo == "NameCompartment")
             {
                 // widget for the property Name
                 _name = new UMLEntry (this, (DI.GraphNode)nestedDiagElem, ChildrensRoot, false, _modelElement.Name);
                 _name.Show();
                 break;
             }
         }
     }
     Redraw ();
 }
예제 #6
0
        public static UMLClassifier CreateNew(
			UMLDiagram ownerDiagram,
			UML.Classifier classifierModel )
        {
            DI.GraphNode classifierGN = UMLBox.CreateNewGraphNode(ownerDiagram, classifierModel);
            return new UMLClassifier (ownerDiagram, classifierGN);
        }
예제 #7
0
 public UMLElement(UMLDiagram ownerDiagram, DI.GraphElement graphElement)
     : base(ownerDiagram.CanvasRoot)
 {
     _ownerDiagram = ownerDiagram;
     _graphElement = graphElement;
     ownerDiagram.AddMapping (graphElement, this);
     _freeEntries = new ArrayList ();
 }
 public static void Execute(UMLDiagram owningDiagram, MonoUML.DI.Point position)
 {
     UML.InstanceSpecification classModel
         = (UML.InstanceSpecification)MonoUML.Widgets.Helper.CreateUmlElement ("InstanceSpecification");
     UMLInstanceSpecification cls = UMLInstanceSpecification.CreateNew (owningDiagram, classModel);
     cls.Move (position.X, position.Y);
     //			owningDiagram.AddNewInstanceSpecification(cls, classModel);
 }
 public UMLInterfaceRealization(UMLDiagram ownerDiagram, DI.GraphEdge interfaceRealizationGraphEdge)
     : this(ownerDiagram, interfaceRealizationGraphEdge, (UML.InterfaceRealization) MonoUML.Widgets.Helper.GetSemanticElement (interfaceRealizationGraphEdge))
 {
     // create the graphic elements that compose this element
     // create the UML canvas elements that compose this UML Element
     Redraw ();
     // create nested stuff
 }
예제 #10
0
 public UMLAssociation(UMLDiagram ownerDiagram, DI.GraphEdge associationGraphEdge)
     : this(ownerDiagram, associationGraphEdge, (UML.Association) MonoUML.Widgets.Helper.GetSemanticElement (associationGraphEdge))
 {
     // create the graphic elements that compose this element
     // create the UML canvas elements that compose this UML Element
     Redraw ();
     // create nested stuff
 }
예제 #11
0
        public static UMLStereotypedEdge CreateNewAndAdd(
			UMLDiagram owningDiagram,
			UML.Relationship stereotypedEdgeModel,
			DI.GraphElement fromGE,
			DI.GraphElement toGE
		)
        {
            // creates the graphical representation of the new Stereotyped Edge
            DI.GraphEdge stereotypedEdgeGE = new DI.GraphEdge ();
            // model semanticModelBridge to the UML model element
            Uml2SemanticModelBridge semanticModelBridge = new Uml2SemanticModelBridge ();
            semanticModelBridge.Element = stereotypedEdgeModel;
            stereotypedEdgeGE.SemanticModel = semanticModelBridge;
            // adds anchors and anchorages
            DI.GraphConnector cnn;

            cnn = new DI.GraphConnector ();
            cnn.GraphElement = fromGE;
            fromGE.Position.CopyTo (cnn.Position);
            fromGE.Anchorage.Add (cnn);
            stereotypedEdgeGE.Anchor.Add (cnn);
            cnn.GraphEdge.Add(stereotypedEdgeGE);

            cnn = new DI.GraphConnector ();
            cnn.GraphElement = toGE;
            toGE.Position.CopyTo (cnn.Position);
            toGE.Anchorage.Add (cnn);
            stereotypedEdgeGE.Anchor.Add (cnn);
            cnn.GraphEdge.Add(stereotypedEdgeGE);
            // adds waypoints
            DI.GraphNode gn = fromGE as DI.GraphNode;
            DI.Point f = (gn != null ? gn.Center : fromGE.Position.Clone ());
            gn = toGE as DI.GraphNode;
            DI.Point t = (gn != null ? gn.Center : toGE.Position.Clone ());
            stereotypedEdgeGE.Waypoints.Add (f);
            stereotypedEdgeGE.Waypoints.Add (t);
            // adds the stereotype compartment
            DI.SimpleSemanticModelElement bridge;
            DI.GraphNode stCompartmentGN = new DI.GraphNode ();
            bridge = new DI.SimpleSemanticModelElement ();
            bridge.TypeInfo = "StereotypeCompartment";
            stCompartmentGN.SemanticModel = bridge;
            stereotypedEdgeGE.Contained.Add (stCompartmentGN);
            stCompartmentGN.Container = stereotypedEdgeGE;
            DI.Point.GetHalfWayPoint (fromGE.Position, toGE.Position).CopyTo (stCompartmentGN.Position);
            DI.GraphNode keywordMetaclassGN = new DI.GraphNode ();
            bridge = new DI.SimpleSemanticModelElement ();
            bridge.TypeInfo = "KeywordMetaclass";
            keywordMetaclassGN.SemanticModel = bridge;
            stCompartmentGN.Contained.Add (keywordMetaclassGN);
            keywordMetaclassGN.Container = stCompartmentGN;
            // adds the stereotypedEdge to the diagram
            owningDiagram.DIDiagram.Contained.Add (stereotypedEdgeGE);
            stereotypedEdgeGE.Container = owningDiagram.DIDiagram;
            UMLStereotypedEdge stereotypedEdge = new UMLStereotypedEdge (owningDiagram, stereotypedEdgeGE, stereotypedEdgeModel);
            owningDiagram.UMLCanvas.AddElement (stereotypedEdge);
            return stereotypedEdge;
        }
예제 #12
0
        public UMLNamedEdge(
			UMLDiagram ownerDiagram,
			DI.GraphEdge graphEdge,
			UML.NamedElement namedElementModel,
			bool forceRedraw)
            : base(ownerDiagram, graphEdge, forceRedraw)
        {
            _namedElementModel = namedElementModel;
            SearchAndDrawName (graphEdge, ownerDiagram);
        }
        private UMLInterfaceRealization(
			UMLDiagram ownerDiagram,
			DI.GraphEdge interfaceRealizationGraphEdge,
			UML.InterfaceRealization interfaceRealizationModel
		)
            : base(ownerDiagram, interfaceRealizationGraphEdge, false)
        {
            _modelElement = interfaceRealizationModel;
            SetEdgeEnds ();
        }
예제 #14
0
        private UMLGeneralization(
			UMLDiagram ownerDiagram,
			DI.GraphEdge generalizationGraphEdge,
			UML.Generalization generalizationModel
		)
            : base(ownerDiagram, generalizationGraphEdge, false)
        {
            _modelElement = generalizationModel;
            SetEdgeEnds ();
        }
예제 #15
0
        private UMLAssociation(
			UMLDiagram ownerDiagram,
			DI.GraphEdge associationGraphEdge,
			UML.Association associationModel
		)
            : base(ownerDiagram, associationGraphEdge, associationModel, false)
        {
            _modelElement = associationModel;
            SetEdgeEnds ();
            SearchAndDrawEndTexts ();
        }
예제 #16
0
        public UMLStereotypedEdge(
			UMLDiagram ownerDiagram,
			DI.GraphEdge graphEdge,
			UML.Relationship edgeModel
		)
            : base(ownerDiagram, graphEdge, false)
        {
            _modelElement = edgeModel;
            base.AddToEnd (new UMLOpenArrow (ChildrensRoot));
            SearchAndDrawStereotype (graphEdge, ownerDiagram);
            base.ForceRedraw ();
        }
예제 #17
0
 protected UMLNode(UMLDiagram ownerDiagram, DI.GraphNode graphNode)
     : base(ownerDiagram, graphNode)
 {
     // hack para evitar un bug...
     // si no hago esto al setear Width repinta todo, con lo cual borra el Height
     _layout_suspended = true;
     _graph_node = graphNode;
      			Width = graphNode.Size.Width;
     Height = graphNode.Size.Height;
     _layout_suspended = false;
     Move (graphNode.Position.X, graphNode.Position.Y);
 }
        public static UMLInterfaceRealization CreateNew(
			UMLDiagram ownerDiagram,
			UMLElement fromElement,
			UMLElement toElement )
        {
            UMLInterfaceRealization interfaceRealization = null;
            DI.GraphElement fromGE = fromElement.GraphElement;
            DI.GraphElement toGE = toElement.GraphElement;
            UML.BehavioredClassifier fromModelElement = MonoUML.Widgets.Helper.GetSemanticElement (fromGE) as UML.BehavioredClassifier;
            UML.Interface toModelElement = MonoUML.Widgets.Helper.GetSemanticElement (toGE) as UML.Interface;
            if (fromModelElement != null && toModelElement != null)
            {
                // creates the new InterfaceRealization in the model
                UML.InterfaceRealization interfaceRealizationModel = UML.Create.InterfaceRealization ();
                interfaceRealizationModel.Contract = toModelElement;
                interfaceRealizationModel.ImplementingClassifier = fromModelElement;
                fromModelElement.InterfaceRealization.Add(interfaceRealizationModel);
                // creates the graphical representation of the new InterfaceRealization
                DI.GraphEdge interfaceRealizationGE = new DI.GraphEdge ();
                //    model bridge to the UML model element (Actor)
                Uml2SemanticModelBridge bridge = new Uml2SemanticModelBridge ();
                bridge.Element = interfaceRealizationModel;
                interfaceRealizationGE.SemanticModel = bridge;
                // adds anchors and anchorages
                DI.GraphConnector cnn;
                cnn = new DI.GraphConnector ();
                cnn.GraphElement = fromGE;
                fromGE.Position.CopyTo (cnn.Position);
                fromGE.Anchorage.Add (cnn);
                interfaceRealizationGE.Anchor.Add (cnn);
                cnn = new DI.GraphConnector ();
                cnn.GraphElement = toGE;
                toGE.Position.CopyTo (cnn.Position);
                toGE.Anchorage.Add (cnn);
                interfaceRealizationGE.Anchor.Add (cnn);
                // adds waypoints
                DI.GraphNode gn = fromGE as DI.GraphNode;
                DI.Point f = (gn != null ? gn.Center : toGE.Position.Clone ());
                gn = toGE as DI.GraphNode;
                DI.Point t = (gn != null ? gn.Center : toGE.Position.Clone ());
                interfaceRealizationGE.Waypoints.Add (f);
                interfaceRealizationGE.Waypoints.Add (t);
                // adds the interfaceRealization to the diagram
                ownerDiagram.DIDiagram.Contained.Add (interfaceRealizationGE);
                interfaceRealization = new UMLInterfaceRealization (ownerDiagram, interfaceRealizationGE, interfaceRealizationModel);
                ownerDiagram.UMLCanvas.AddElement (interfaceRealization);
                Hub.Instance.Broadcaster.BroadcastElementChange(fromModelElement);
            }
            return interfaceRealization;
        }
예제 #19
0
 // returns the classifier that is under the mouse pointer
 public static UML.Classifier GetHoverClassifier(UMLDiagram ownerDiagram, object ignoredElement)
 {
     UML.Classifier hoverClassifier = null;
     UMLElement hoverElement = ownerDiagram.UMLCanvas.GetHoverElement (ignoredElement);
     // checks that the new model element is a Classifier
     if (hoverElement != null)
     {
         UML.Element hoverModel = MonoUML.Widgets.Helper.GetSemanticElement (hoverElement.GraphElement);
         if (hoverModel != null)
         {
             hoverClassifier = hoverModel as UML.Classifier;
         }
     }
     return hoverClassifier;
 }
예제 #20
0
 public UMLActor(UMLDiagram ownerDiagram, DI.GraphNode actorGraphNode)
     : base(ownerDiagram, actorGraphNode)
 {
     // old ctor
     _head = new CanvasEllipse (ChildrensRoot);
     _head.OutlineColor = DEFAULT_OUTLINE_COLOR;
     _head.FillColor = DEFAULT_FILL_COLOR;
     //
     _arms = new CanvasLine (ChildrensRoot);
     _arms.WidthUnits = 1.0;
     _arms.FillColor = DEFAULT_OUTLINE_COLOR;
     //
     _body = new CanvasLine (ChildrensRoot);
     _body.WidthUnits = 1.0;
     _body.FillColor = DEFAULT_OUTLINE_COLOR;
     //
     _legs = new CanvasLine (ChildrensRoot);
     _legs.WidthUnits= 1.0;
     _legs.FillColor = DEFAULT_OUTLINE_COLOR;
     // /old ctor
     _modelElement = (UML.Actor) MonoUML.Widgets.Helper.GetSemanticElement (actorGraphNode);
     DI.GraphElement nestedDiagElem;
     DI.SimpleSemanticModelElement nestedBridge;
     //
     DI.DiagramElement elem = (DI.DiagramElement) actorGraphNode.Contained[0];
     nestedDiagElem = elem as DI.GraphElement;
     if (nestedDiagElem != null)
     {
         nestedBridge = nestedDiagElem.SemanticModel as DI.SimpleSemanticModelElement;
         if (nestedBridge.TypeInfo == "Name")
         {
             string fontModifier = (_modelElement.IsAbstract ? "italic" : "");
             _nameUMLEntry = new UMLEntry (this, (DI.GraphNode)nestedDiagElem, ownerDiagram.CanvasRoot, true, _modelElement.Name, fontModifier);
             base.AddFreeEntry (_nameUMLEntry);
             _nameUMLEntry.Show ();
             _nameDIGraphNode = nestedDiagElem;
         }
     }
     else
     {
         //TODO: Create both, entry and DI nested element
     }
     _nameUMLEntry.TextChanged += CallHub;
     Redraw ();
 }
예제 #21
0
		public UMLCanvas (UMLDiagram diagram) : base ()
		{
			ShadowType = ShadowType.In;

			_diagram = diagram;

			//Canvas' details
			_canvas = Canvas.NewAa ();
			_canvas.Dither = Gdk.RgbDither.None;
			Canvas.NewAa();
			System.Console.WriteLine("Dither: {0}", _canvas.Dither);
			DI.Diagram diDiagram = diagram.DIDiagram;
			DI.Dimension canvasSize = diDiagram.Size;
			_canvas.WidthRequest = (int)canvasSize.Width;
			_canvas.HeightRequest = (int)canvasSize.Height;
			System.Console.WriteLine ("diDiagram.Zoom: " +diDiagram.Zoom);
			if (diDiagram.Zoom > 0)
			{
				_canvas.PixelsPerUnit = diDiagram.Zoom;
			}
			_canvas.SetScrollRegion (0.0, 0.0, 1200, 750);			
			_canvas.ButtonPressEvent += ButtonPressEventCb;
			_canvas.ButtonReleaseEvent += ButtonReleaseEventCb;
			_canvas.MotionNotifyEvent += MotionNotifyEventCb;
			//_canvas.SizeAllocated +=SizeAllocatedCb;
			
			InitBackGroup ();
			InitFrontGroup ();
			
			//Selector details
			_selector = new UMLSelector (_canvas.Root());
			_elements = new ArrayList();
			//_edges = new ArrayList();

			Add (_canvas);
			Grid = true;
			SizeAllocated += ChangeCanvasSize;
			
			//Drag&Drop
			Gtk.Drag.DestSet (_canvas, DestDefaults.All, _fromTree, Gdk.DragAction.Copy);
			_canvas.DragDataReceived += DataReceived;			
		}
예제 #22
0
 public UMLUseCase(UMLDiagram ownerDiagram, DI.GraphNode graphNode)
     : base(ownerDiagram, graphNode)
 {
     _circle = new CanvasEllipse (ChildrensRoot);
     _circle.X1 = _circle.Y1 = 0;
     _circle.X2 = Width;
     _circle.Y2 = Height;
     _circle.FillColor = DEFAULT_FILL_COLOR;
     _circle.OutlineColor = DEFAULT_OUTLINE_COLOR;
     //
     Width = GraphNode.Size.Width;
     Height = GraphNode.Size.Height;
     //
     Uml2SemanticModelBridge bridge = (Uml2SemanticModelBridge) GraphNode.SemanticModel;
     _modelElement = (UML.UseCase) bridge.Element;
     DI.GraphElement nestedDiagElem;
     DI.SimpleSemanticModelElement nestedBridge;
     //
     foreach (DI.DiagramElement elem in GraphNode.Contained)
     {
         nestedDiagElem = elem as DI.GraphElement;
         if (nestedDiagElem != null)
         {
             nestedBridge = nestedDiagElem.SemanticModel as DI.SimpleSemanticModelElement;
             System.Console.WriteLine ("UMLUseCase nestedBridge.TypeInfo "+nestedBridge.TypeInfo);
             if (nestedBridge.TypeInfo == "NameCompartment")
             {
                 // widget for the property Name
                 string fontModifier = (_modelElement.IsAbstract ? "italic" : "");
                 _name = new UMLEntry (this, (DI.GraphNode)nestedDiagElem, ChildrensRoot, false, _modelElement.Name, fontModifier);
                 _name.Show();
                 break;
             }
         }
     }
     _circle.X1 = _circle.Y1 = 0;
     _circle.X2 = Width;
     _circle.Y2 = Height;
     Redraw ();
 }
예제 #23
0
        public static void Execute(
			UMLDiagram owningDiagram, 
			UMLElement fromElement, 
			UMLElement toElement
		)
        {
            DI.GraphElement fromGE = fromElement.GraphElement;
            DI.GraphElement toGE = toElement.GraphElement;
            UML.UseCase includingCase = MonoUML.Widgets.Helper.GetSemanticElement (fromGE) as UML.UseCase;
            UML.UseCase addition = MonoUML.Widgets.Helper.GetSemanticElement (toGE) as UML.UseCase;
            if (includingCase != null && addition != null)
            {
                // creates the new Include in the model
                UML.Include includeModel = UML.Create.Include ();
                includingCase.Include.Add (includeModel);
                includeModel.IncludingCase = includingCase;
                includeModel.Addition = addition;
                // creates the graphical representation of the new Include
                UMLStereotypedEdge.CreateNewAndAdd (owningDiagram, includeModel, fromGE, toGE);
                Hub.Instance.Broadcaster.BroadcastElementChange (includingCase);
            }
        }
예제 #24
0
        public ToolbarBase(UMLDiagram diagram)
            : base()
        {
            _diagram = diagram;
            ToolbarStyle = ToolbarStyle.Icons;
            Tooltips = true;
            _tooltips  = new Tooltips ();

            _tbuttonGrid = new ToggleToolButton ();
            _tbuttonGrid.IconWidget = new Gtk.Image (MonoUML.IconLibrary.PixbufLoader.GetIcon ("grid_tbar.png"));
            _tbuttonGrid.SetTooltip (_tooltips, GettextCatalog.GetString ("Show grid"), GettextCatalog.GetString ("Show grid"));

            _tbuttonSnap2Grid = new ToggleToolButton ();
            _tbuttonSnap2Grid.IconWidget = new Gtk.Image (MonoUML.IconLibrary.PixbufLoader.GetIcon ("snap2grid_tbar.png"));
            _tbuttonSnap2Grid.SetTooltip (_tooltips, GettextCatalog.GetString ("Snap to grid"), GettextCatalog.GetString ("Snap to grid"));

            Insert (_tbuttonGrid, -1);
            Insert (_tbuttonSnap2Grid, -1);
            InsertSeparator ();

            DrawIcons ();
        }
예제 #25
0
        public static void Execute(
			UMLDiagram owningDiagram, 
			UMLElement fromElement, 
			UMLElement toElement
		)
        {
            DI.GraphElement fromGE = fromElement.GraphElement;
            DI.GraphElement toGE = toElement.GraphElement;
            UML.UseCase extension = MonoUML.Widgets.Helper.GetSemanticElement (fromGE) as UML.UseCase;
            UML.UseCase extendedCase = MonoUML.Widgets.Helper.GetSemanticElement (toGE) as UML.UseCase;
            if (extension != null && extendedCase != null)
            {
                // creates the new Extend in the model
                UML.Extend extendModel = UML.Create.Extend ();
                extension.Extend.Add (extendModel);
                extendModel.Extension = extension;
                extendModel.ExtendedCase = extendedCase;
                // creates the graphical representation of the new Extend
                UMLStereotypedEdge.CreateNewAndAdd (owningDiagram, extendModel, fromGE, toGE);
                Hub.Instance.Broadcaster.BroadcastElementChange (extension);
            }
        }
예제 #26
0
        public static UMLAssociation CreateNew(
			UMLDiagram ownerDiagram,
			UMLElement fromElement,
			UMLElement toElement )
        {
            UMLAssociation association = null;
            DI.GraphElement fromGE = fromElement.GraphElement;
            DI.GraphElement toGE = toElement.GraphElement;
            UML.Classifier fromModelElement = MonoUML.Widgets.Helper.GetSemanticElement (fromGE) as UML.Classifier;
            UML.Classifier toModelElement = MonoUML.Widgets.Helper.GetSemanticElement (toGE) as UML.Classifier;
            if (fromModelElement != null && toModelElement != null)
            {
                // creates the new Association in the model
                UML.Association assocModel = UML.Create.Association ();
                UML.Property end0 = UML.Create.Property ();
                // the first end aims at the "TO" end
                end0.Type = toModelElement;
                assocModel.OwnedEnd.Add (end0);
                end0.OwningAssociation = assocModel;
                // the second (and last) end aims at the "FROM" end
                UML.Property end1 = UML.Create.Property ();
                end1.Type = fromModelElement;
                assocModel.OwnedEnd.Add (end1);
                end1.OwningAssociation = assocModel;
                // creates the graphical representation of the new Association
                DI.GraphEdge assocGE = new DI.GraphEdge ();
                //    graphical properties
                //    model bridge to the UML model element (Actor)
                Uml2SemanticModelBridge bridge = new Uml2SemanticModelBridge ();
                bridge.Element = assocModel;
                assocGE.SemanticModel = bridge;
                // adds anchors and anchorages
                DI.GraphConnector cnn;
                cnn = new DI.GraphConnector ();
                cnn.GraphElement = fromGE;
                fromGE.Anchorage.Add (cnn);
                fromGE.Position.CopyTo (cnn.Position);
                assocGE.Anchor.Add (cnn);
                cnn.GraphEdge.Add (assocGE);
                cnn = new DI.GraphConnector ();
                cnn.GraphElement = toGE;
                toGE.Anchorage.Add (cnn);
                toGE.Position.CopyTo (cnn.Position);
                assocGE.Anchor.Add (cnn);
                cnn.GraphEdge.Add (assocGE);
                // adds waypoints
                DI.GraphNode gn = fromGE as DI.GraphNode;
                DI.Point f = (gn != null ? gn.Center : toGE.Position.Clone ());
                gn = toGE as DI.GraphNode;
                DI.Point t = (gn != null ? gn.Center : toGE.Position.Clone ());
                assocGE.Waypoints.Add (f);
                assocGE.Waypoints.Add (t);
                // adds the name compartment
                DI.SimpleSemanticModelElement simpleBridge;
                DI.GraphNode nameCompartmentGN = new DI.GraphNode ();
                simpleBridge = new DI.SimpleSemanticModelElement ();
                simpleBridge.TypeInfo = "DirectedName";
                nameCompartmentGN.SemanticModel = simpleBridge;
                assocGE.Contained.Add (nameCompartmentGN);
                nameCompartmentGN.Container = assocGE;
                DI.Point.GetHalfWayPoint (fromGE.Position, toGE.Position).CopyTo (nameCompartmentGN.Position);
                DI.GraphNode keywordMetaclassGN = new DI.GraphNode ();
                simpleBridge = new DI.SimpleSemanticModelElement ();
                simpleBridge.TypeInfo = "Name";
                keywordMetaclassGN.SemanticModel = simpleBridge;
                nameCompartmentGN.Contained.Add (keywordMetaclassGN);
                keywordMetaclassGN.Container = nameCompartmentGN;
                // adds the association ends compartments
                DI.GraphNode endCompartment0 = UMLAssociationEnd.CreateNewGraphNode (end0);
                assocGE.Contained.Add (endCompartment0);
                endCompartment0.Container = assocGE;
                DI.GraphNode endCompartment1 = UMLAssociationEnd.CreateNewGraphNode (end1);
                assocGE.Contained.Add (endCompartment1);
                endCompartment1.Container = assocGE;
                // adds the association to the diagram
                ownerDiagram.DIDiagram.Contained.Add (assocGE);
                assocGE.Container = ownerDiagram.DIDiagram;
                association = new UMLAssociation (ownerDiagram, assocGE, assocModel);
                association._assocEnd0.SetPosition ((DI.Point) association._graphEdge.Waypoints [0]);
                association._assocEnd1.SetPosition ((DI.Point) association._graphEdge.Waypoints [1]);
                ownerDiagram.AddNewClassifier (association, assocModel);
            }
            return association;
        }
예제 #27
0
 public static void Execute(UMLDiagram owningDiagram)
 {
     Execute (owningDiagram, new MonoUML.DI.Point (0, 0));
 }
예제 #28
0
 public UMLAssociationEnd(UMLDiagram ownerDiagram, DI.GraphNode graphNode)
     : base(ownerDiagram, graphNode)
 {
     _circle = new CanvasEllipse (ownerDiagram.CanvasRoot);
     _circle.OutlineColorGdk = UMLEdge.HIGHLIGHTED_OUTLINE_COLOR;
     _graphNode = graphNode;
     _modelElement = (UML.Property) MonoUML.Widgets.Helper.GetSemanticElement (graphNode);
     DI.SimpleSemanticModelElement bridge;
     foreach (DI.GraphNode gn in graphNode.Contained)
     {
         bridge = gn.SemanticModel as DI.SimpleSemanticModelElement;
         switch (bridge.TypeInfo)
         {
             case "Name":
                 _name = new UMLEntry (this, gn, ownerDiagram.CanvasRoot, true, _modelElement.Name);
                 _name.TextChanged += new UMLElementNameChangedHandler (BroadcastNameChange);
                 base.AddFreeEntry (_name);
                 _name.Show ();
                 break;
             case "Visibility":
                 break;
             case "Multiplicity":
                 _multiplicity = new UMLEntry (this, gn, ownerDiagram.CanvasRoot, true, GetMultiplicity ());
                 _multiplicity.TextChanged += new UMLElementNameChangedHandler (ApplyMultiplicityChange);
                 base.AddFreeEntry (_multiplicity);
                 _multiplicity.Show ();
                 break;
         }
     }
 }
예제 #29
0
 public ToolbarUseCase(UMLDiagram diagram)
     : base(diagram)
 {
     _actionActor = new CreateActorAction (diagram);
     _actionUseCase = new CreateUseCaseAction (diagram);
 }
예제 #30
0
 public CreateIncludeAction(UMLDiagram owningDiagram)
     : base(owningDiagram)
 {
 }