Exemple #1
0
        /// <summary>
        /// Turn an accessibleObject into an element in the underlying model.
        /// </summary>
        /// <param name="accessibleObject">The accessible object</param>
        /// <param name="returnShape">True to return the shape object corresponding to the
        /// accessible object instead of the underlying model element. Note that you may get
        /// a shape for a parent object if the requested accessible object is drawn as part
        /// of another object and does not have its own shape (roles, internal uniqueness constraints, etc)</param>
        /// <returns>ModelElement, or null</returns>
        public ModelElement TranslateAccessibleObject(AccessibleObject accessibleObject, bool returnShape)
        {
            DiagramItem hitItem = TranslateAccessibleObjectToDiagramItem(accessibleObject, returnShape);

            if (hitItem == null)
            {
                return(null);
            }
            else if (returnShape)
            {
                return(hitItem.Shape);
            }
            else
            {
                ModelElement retVal = null;
                foreach (object element in hitItem.RepresentedElements)
                {
                    retVal = element as ModelElement;
                    break;
                }
                PresentationElement pel = retVal as PresentationElement;
                if (pel != null)
                {
                    // Resolve to a ModelElement if we don't have one already
                    retVal = pel.ModelElement;
                }
                return(retVal);
            }
        }
Exemple #2
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method.
        /// </summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information.</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services.</param>
        /// <param name="value">The object to edit.</param>
        /// <returns>
        /// The new value of the object. If the value of the object has not changed, this should return the same object it was passed.
        /// </returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            PresentationElement shape = context.Instance as PresentationElement;

            if (shape == null)
            {
                return(value);
            }

            _externalAssembly = shape.ModelElement as DotNetAssembly;
            if (_externalAssembly == null)
            {
                return(value);
            }

            using (
                Transaction transaction =
                    _externalAssembly.Store.TransactionManager.BeginTransaction("Retrieve assembly infos"))
            {
                IAssemblySelectorDialog selector = ServiceLocator.Instance.GetService <IAssemblySelectorDialog>();
                if (selector.ShowDialog(1))
                {
                    _externalAssembly.InitFromAssembly(selector.SelectedAssemblies[0], true);

                    // Vérification si il n'y a pas des relations orphelines
                    // TODO
                    transaction.Commit();
                }
            }

            return(value);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ShowStrategiesCommand"/> class.
        /// </summary>
        /// <param name="component">The component.</param>
        /// <param name="element">The element.</param>
        /// <param name="fileName">Name of the file.</param>
        public ShowStrategiesCommand(SoftwareComponent component, object element, string fileName)
        {
            this._component = component;
            PresentationElement pel = element as PresentationElement;

            if (pel != null)
            {
                this._model = pel.ModelElement as CandleElement;
            }
        }
Exemple #4
0
 public static void UpdatePresentationElement <T>(this ModelElement modelElement, Action <T> updateAction) where T : PresentationElement
 {
     if (PresentationViewsSubject.GetPresentation(modelElement).Count == 1)
     {
         PresentationElement presentationElement = PresentationViewsSubject.GetPresentation(modelElement)[0];
         T pe = presentationElement as T;
         if (pe != null)
         {
             updateAction(pe);
         }
     }
 }
Exemple #5
0
        // Affichage de la fenêtre de détail pour les opérations d'un port
        /// <summary>
        /// Shows the window pane for port.
        /// </summary>
        /// <param name="portShape">The port shape.</param>
        public void ShowWindowPaneForPort(PresentationElement portShape)
        {
            PortWindowPane wnd = (PortWindowPane)package.GetToolWindow(typeof(PortWindowPane), true);

            if (wnd == null)
            {
                // Accés au package
                wnd = (PortWindowPane)package.GetToolWindow(typeof(PortWindowPane), true);
            }
            if (wnd != null)
            {
                wnd.ShowNoActivate();
                wnd.SetSelection(portShape);
            }
        }
        /// <summary>
        /// Get the underlying object type for a presentation element
        /// </summary>
        /// <param name="shape">A presentation element.</param>
        /// <returns>An ObjectType, or null</returns>
        protected static ObjectType ObjectTypeFromShape(PresentationElement shape)
        {
            ObjectType   objectType = null;
            FactType     factType;
            ModelElement backingElement = (shape != null) ? shape.ModelElement : null;

            if (null == (objectType = backingElement as ObjectType))
            {
                if (null != (factType = backingElement as FactType))
                {
                    objectType = factType.NestingType;
                }
            }
            return(objectType);
        }
Exemple #7
0
        public static ModelElement GetModelElement(object target)
        {
            ModelElement        element      = null;
            PresentationElement presentation = target as PresentationElement;

            if (presentation != null)
            {
                if (presentation.Subject != null)
                {
                    element = presentation.Subject;
                }
            }
            else
            {
                element = target as ModelElement;
            }
            return(element);
        }
Exemple #8
0
        private static void InvalidateRemainingShapes(ModelElement backingElement, ShapeElement ignoreShape)
        {
            LinkedElementCollection <PresentationElement> pels = PresentationViewsSubject.GetPresentation(backingElement);
            int pelCount = pels.Count;

            if (ignoreShape == null || pelCount > 1)
            {
                for (int i = 0; i < pelCount; ++i)
                {
                    PresentationElement pel = pels[i];
                    ShapeElement        updateShape;
                    if (pel != ignoreShape &&
                        null != (updateShape = pel as ShapeElement) &&
                        updateShape is IDisplayMultiplePresentations)
                    {
                        updateShape.Invalidate();
                    }
                }
            }
        }
        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        {
            // BUG: the value of context.Instance should always be the entity itself, since the
            // domain property is defined on the Entity class. However, currently it is shape, if
            // you select it on the design surface. Code below works around this.


            PresentationElement pe = context.Instance as PresentationElement;

            if (pe != null)
            {
                //entity = pe.ModelElement as Entity;
                connection = pe.ModelElement as SchemaModelItemHasSchemaModelItem;
                if (connection != null)
                {
                    selected = true;
                    return(true);
                }
                else
                {
                    selected = false;
                }
                return(false);
            }
            else
            {
                connection = context.Instance as SchemaModelItemHasSchemaModelItem;
                if (connection != null)
                {
                    selected = true;
                    return(true);
                }
                else
                {
                    selected = false;
                }
                return(false);
            }

            //return connection != null ? true : false;
        }
Exemple #10
0
        private void UpdateVerbalization()
        {
            if (CurrentORMSelectionContainer == null)
            {
                return;
            }
            if (myStringWriter != null)
            {
                myStringWriter.GetStringBuilder().Length = 0;

                ICollection selectedObjects = base.GetSelectedComponents();
                IDictionary <Type, IVerbalizationSets>            snippetsDictionary = null;
                IDictionary <string, object>                      options            = null;
                IVerbalizationSets <CoreVerbalizationSnippetType> snippets           = null;
                IExtensionVerbalizerService extensionVerbalizer = null;
                VerbalizationCallbackWriter callbackWriter      = null;
                bool showNegative     = ORMDesignerPackage.VerbalizationWindowSettings.ShowNegativeVerbalizations;
                bool firstCallPending = true;
                Dictionary <IVerbalize, IVerbalize> alreadyVerbalized = myAlreadyVerbalized;
                if (alreadyVerbalized == null)
                {
                    alreadyVerbalized   = new Dictionary <IVerbalize, IVerbalize>();
                    myAlreadyVerbalized = alreadyVerbalized;
                }
                else
                {
                    alreadyVerbalized.Clear();
                }
                Dictionary <object, object> locallyVerbalized = myLocallyVerbalized;
                if (locallyVerbalized == null)
                {
                    locallyVerbalized   = new Dictionary <object, object>();
                    myLocallyVerbalized = locallyVerbalized;
                }
                if (selectedObjects != null)
                {
                    foreach (object melIter in selectedObjects)
                    {
                        ModelElement        mel       = melIter as ModelElement;
                        PresentationElement pel       = mel as PresentationElement;
                        ModelElement        secondMel = null;
                        if (pel != null)
                        {
                            IRedirectVerbalization shapeRedirect = pel as IRedirectVerbalization;
                            bool redirected = null != (shapeRedirect = pel as IRedirectVerbalization) &&
                                              null != (mel = shapeRedirect.SurrogateVerbalizer as ModelElement);

                            if (!redirected)
                            {
                                mel = pel.ModelElement;
                            }

                            if (pel is IVerbalizeCustomChildren ||
                                (!redirected && pel is IVerbalize || pel is IVerbalizeChildren))
                            {
                                secondMel = mel;
                                mel       = pel;
                            }
                        }
                        while (mel != null && !mel.IsDeleted)
                        {
                            if (snippetsDictionary == null)
                            {
                                Store store = Utility.ValidateStore(mel.Store);
                                if (store == null)
                                {
                                    break;
                                }
                                IORMToolServices toolServices = (IORMToolServices)store;
                                extensionVerbalizer = toolServices.ExtensionVerbalizerService;
                                options             = toolServices.VerbalizationOptions;
                                snippetsDictionary  = toolServices.GetVerbalizationSnippetsDictionary(ORMCoreDomainModel.VerbalizationTargetName);
                                snippets            = (IVerbalizationSets <CoreVerbalizationSnippetType>)snippetsDictionary[typeof(CoreVerbalizationSnippetType)];
                                callbackWriter      = new VerbalizationCallbackWriter(snippets, myStringWriter, GetDocumentHeaderReplacementFields(mel, snippets));
                            }
                            locallyVerbalized.Clear();
                            VerbalizationHelper.VerbalizeElement(
                                mel,
                                snippetsDictionary,
                                extensionVerbalizer,
                                options,
                                ORMCoreDomainModel.VerbalizationTargetName,
                                alreadyVerbalized,
                                locallyVerbalized,
                                (showNegative ? VerbalizationSign.Negative : VerbalizationSign.Positive) | VerbalizationSign.AttemptOppositeSign,
                                callbackWriter,
                                true,
                                ref firstCallPending);

                            if (secondMel != null)
                            {
                                mel       = secondMel;
                                secondMel = null;
                            }
                            else
                            {
                                mel = null;
                            }
                        }
                    }
                }
                if (!firstCallPending)
                {
                    // Write footer
                    callbackWriter.WriteDocumentFooter();
                    // Clear cache
                    alreadyVerbalized.Clear();
                }
                else
                {
                    // Nothing happened, put in text for nothing happened
                }
                WebBrowser browser = myWebBrowser;
                if (browser != null)
                {
                    browser.DocumentText = myStringWriter.ToString();
                }
            }
        }
Exemple #11
0
 public static TElement GetElementFromShape <TElement>(PresentationElement element)
     where TElement : ModelElement
 {
     return(PresentationViewsSubject.GetSubject(element) as TElement);
 }
 // utilities for binding fields and domain properties
 private static ModelElement presentationToDomain(PresentationElement presentation)
 {
     // presentation is WidgetTitle
     return(((NodeShape)presentation).ParentShape);
 }
 // utilities for binding fields and domain properties
 private static ModelElement presentationToDomain(PresentationElement presentation)
 {
     // presentation is WidgetTitle
     return ((NodeShape)presentation).ParentShape;
 }
Exemple #14
0
 /// <summary>
 /// Get the underlying element for a presentation element
 /// </summary>
 /// <typeparam name="ElementType">The type of the element to retrieve</typeparam>
 /// <param name="shape">A presentation element.</param>
 /// <returns>An ElementType element, or null</returns>
 protected static ElementType ElementFromShape <ElementType>(PresentationElement shape) where ElementType : ModelElement
 {
     return(((shape != null) ? shape.ModelElement : null) as ElementType);
 }
		/// <summary>
		/// Get the underlying object type for a presentation element
		/// </summary>
		/// <param name="shape">A presentation element.</param>
		/// <returns>An ObjectType, or null</returns>
		protected static ObjectType ObjectTypeFromShape(PresentationElement shape)
		{
			ObjectType objectType = null;
			FactType factType;
			ModelElement backingElement = (shape != null) ? shape.ModelElement : null;
			if (null == (objectType = backingElement as ObjectType))
			{
				if (null != (factType = backingElement as FactType))
				{
					objectType = factType.NestingType;
				}
			}
			return objectType;
		}