From: <mcu...@us...> - 2007-08-20 22:24:43
|
Revision: 1094 http://orm.svn.sourceforge.net/orm/?rev=1094&view=rev Author: mcurland Date: 2007-08-20 15:24:39 -0700 (Mon, 20 Aug 2007) Log Message: ----------- Added ability to bold items in the model browser. refs #268 Added bolding for non-nullable columns, overlays for primary identifier columns, and sorted primary columns to the top of the column list. refs #328 Modified Paths: -------------- trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/MainList.cs trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/SurveyInterfaces.cs trunk/ORMModel/ObjectModel/ORMCore.SurveyQuestionProvider.cs trunk/ORMModel/Transforms/SurveyQuestionProvider.xsd trunk/ORMModel/Transforms/SurveyQuestionProvider.xslt trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.cs trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.xml trunk/RelationalModel/DcilModel/Resources/SurveyTree.ImageStrip.png trunk/RelationalModel/DcilModel/SurveyImplementations/SurveyQuestions.cs Modified: trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/MainList.cs =================================================================== --- trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/MainList.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/MainList.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -317,35 +317,50 @@ for (int i = 0; i < questionCount; i++) { SurveyQuestion question = mySurvey[i]; - if (0 != (question.Question.UISupport & SurveyQuestionUISupport.Glyph)) + ISurveyQuestionTypeInfo questionInfo = question.Question; + SurveyQuestionUISupport support = questionInfo.UISupport; + if (0 != (support & (SurveyQuestionUISupport.Glyph | SurveyQuestionUISupport.Overlay | SurveyQuestionUISupport.DisplayData))) { - int answer; - if (image == -1 && - SurveyQuestion.NeutralAnswer != (answer = myCurrentDisplays[i].Question.ExtractAnswer(nodeData)) && - 0 <= (image = question.Question.MapAnswerToImageIndex(answer))) + int answer = myCurrentDisplays[i].Question.ExtractAnswer(nodeData); + if (answer != SurveyQuestion.NeutralAnswer) { - image += question.ProviderImageListOffset; - } - } - else if (0 != (question.Question.UISupport & SurveyQuestionUISupport.Overlay)) - { - int answer; - if (SurveyQuestion.NeutralAnswer != (answer = myCurrentDisplays[i].Question.ExtractAnswer(nodeData)) && - 0 <= (answer = question.Question.MapAnswerToImageIndex(answer))) - { - if (overlayImage == -1) + // Extract image and overlay support + if (0 != (support & SurveyQuestionUISupport.Glyph)) { - overlayImage = answer + question.ProviderImageListOffset; + if (image == -1 && + 0 <= (image = questionInfo.MapAnswerToImageIndex(answer))) + { + image += question.ProviderImageListOffset; + } } - else + else if (0 != (support & SurveyQuestionUISupport.Overlay)) { - if (overlayBitField == -1) + int answerImage = questionInfo.MapAnswerToImageIndex(answer); + if (0 <= answerImage) { - overlayBitField = 0; - AddToOverlayList(overlayImage, ref overlayBitField); + if (overlayImage == -1) + { + overlayImage = answerImage + question.ProviderImageListOffset; + } + else + { + if (overlayBitField == -1) + { + overlayBitField = 0; + AddToOverlayList(overlayImage, ref overlayBitField); + } + AddToOverlayList(answerImage + question.ProviderImageListOffset, ref overlayBitField); + } } - AddToOverlayList(answer + question.ProviderImageListOffset, ref overlayBitField); } + + // Extract other display settings + if (0 != (support & SurveyQuestionUISupport.DisplayData)) + { + SurveyQuestionDisplayData displayData = questionInfo.GetDisplayData(answer); + retVal.Bold = displayData.Bold; + retVal.GrayText = displayData.GrayText; + } } } } Modified: trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/SurveyInterfaces.cs =================================================================== --- trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/SurveyInterfaces.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/Framework/Shell/DynamicSurveyTreeGrid/SurveyInterfaces.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -56,6 +56,11 @@ /// <see cref="ISurveyQuestionTypeInfo.MapAnswerToImageIndex"/> method. /// </summary> Overlay = 8, + /// <summary> + /// Question supports additional display settings with the + /// <see cref="ISurveyQuestionTypeInfo.GetDisplayData"/> method. + /// </summary> + DisplayData = 0x10, } #endregion // SurveyQuestionUISupport enum #region ISurveyQuestionProvider interface @@ -86,6 +91,61 @@ IEnumerable<Type> GetErrorDisplayTypes(); } #endregion // ISurveyQuestionProvider interface + #region SurveyQuestionDisplayData structure + /// <summary> + /// Associate additional display information with this question. + /// Used by the <see cref="ISurveyQuestionTypeInfo.GetDisplayData"/> method. + /// </summary> + public struct SurveyQuestionDisplayData + { + private bool myIsBold; + private bool myIsGrayText; + /// <summary> + /// Default display settings + /// </summary> + public static readonly SurveyQuestionDisplayData Default = new SurveyQuestionDisplayData(); + /// <summary> + /// Create a new <see cref="SurveyQuestionDisplayData"/> + /// </summary> + /// <param name="isBold">Display text as bold</param> + /// <param name="isGrayText">Display text as gray text</param> + public SurveyQuestionDisplayData(bool isBold, bool isGrayText) + { + myIsBold = isBold; + myIsGrayText = isGrayText; + } + /// <summary> + /// Return <see langword="true"/> if these are the default settings + /// </summary> + public bool IsDefault + { + get + { + return !(myIsBold || myIsGrayText); + } + } + /// <summary> + /// Should the text display bold? + /// </summary> + public bool Bold + { + get + { + return myIsBold; + } + } + /// <summary> + /// Should the text display gray? + /// </summary> + public bool GrayText + { + get + { + return myIsGrayText; + } + } + } + #endregion // SurveyQuestionDisplayData structure #region ISurveyQuestionTypeInfo interface /// <summary> /// Holds a reference to a specific type of question and method for asking question of objects @@ -114,6 +174,13 @@ /// <returns>0-based index into the image list.</returns> int MapAnswerToImageIndex(int answer); /// <summary> + /// Retrieves additional display information for a given answer. Used only if + /// <see cref="UISupport"/> indicates support for <see cref="SurveyQuestionUISupport.DisplayData"/> + /// </summary> + /// <param name="answer">A value from the enum type returned by the <see cref="QuestionType"/> property.</param> + /// <returns><see cref="SurveyQuestionDisplayData"/> settings</returns> + SurveyQuestionDisplayData GetDisplayData(int answer); + /// <summary> /// UISupport for Question /// </summary> SurveyQuestionUISupport UISupport { get;} Modified: trunk/ORMModel/ObjectModel/ORMCore.SurveyQuestionProvider.cs =================================================================== --- trunk/ORMModel/ObjectModel/ORMCore.SurveyQuestionProvider.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/ObjectModel/ORMCore.SurveyQuestionProvider.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -82,6 +82,10 @@ { return -1; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -126,6 +130,10 @@ } return retVal; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -160,6 +168,10 @@ { return answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -194,6 +206,10 @@ { return -1; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get Modified: trunk/ORMModel/Transforms/SurveyQuestionProvider.xsd =================================================================== --- trunk/ORMModel/Transforms/SurveyQuestionProvider.xsd 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/Transforms/SurveyQuestionProvider.xsd 2007-08-20 22:24:39 UTC (rev 1094) @@ -91,10 +91,65 @@ <xs:sequence> <xs:element ref="displaySupport" maxOccurs="unbounded"/> <xs:element ref="imageMap" minOccurs="0"/> + <xs:element ref="displayDataMap" minOccurs="0"/> </xs:sequence> <xs:attribute name="questionType" type="xs:string" use="required"/> <xs:attribute name="isErrorDisplay" type="xs:boolean" default="false"/> </xs:complexType> + <xs:element name="displayDataMap" type="displayDataMapType"> + <xs:unique name="DisplayDataUnique"> + <xs:selector xpath="qp:displayData | qp:displayDataSameAs"/> + <xs:field xpath="@enumValue"/> + </xs:unique> + <xs:key name="DisplayDataKey"> + <xs:selector xpath="qp:displayData"/> + <xs:field xpath="@enumValue"/> + </xs:key> + <xs:keyref name="DisplayDataSameAsKeyRef" refer="DisplayDataKey"> + <xs:selector xpath="qp:displayDataSameAs"/> + <xs:field xpath="@targetEnumValue"/> + </xs:keyref> + </xs:element> + <xs:complexType name="displayDataMapType"> + <xs:annotation> + <xs:documentation>Associate an answer with different display data settings.</xs:documentation> + </xs:annotation> + <xs:choice maxOccurs="unbounded"> + <xs:element name="displayData"> + <xs:complexType> + <xs:attribute name="enumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>The value from the questionType enum to associate with these display settings.</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="bold" type="xs:boolean" default="false"> + <xs:annotation> + <xs:documentation>Display answers from this category in bold text</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="gray" type="xs:boolean" default="false"> + <xs:annotation> + <xs:documentation>Display answers from this category in gray text</xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + </xs:element> + <xs:element name="displayDataSameAs"> + <xs:complexType> + <xs:attribute name="enumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>The value from the questionType enum to associate with these display settings.</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="targetEnumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>This value should have the same display settings as the targeted value.</xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + </xs:element> + </xs:choice> + </xs:complexType> <xs:complexType name="imageMapType"/> <xs:element name="imageMap" abstract="true" type="imageMapType"/> <xs:element name="sequentialImageMap" type="sequentialImageMapType" substitutionGroup="imageMap"> @@ -121,24 +176,40 @@ </xs:extension> </xs:complexContent> </xs:complexType> - <xs:element name="explicitImageMap" type="explicitImageMapType" substitutionGroup="imageMap"/> + <xs:element name="explicitImageMap" type="explicitImageMapType" substitutionGroup="imageMap"> + <xs:unique name="ExplicitImageMapUnique"> + <xs:selector xpath="qp:map | qp:mapSameAs"/> + <xs:field xpath="@enumValue"/> + </xs:unique> + <xs:key name="ExplicitImageMapKey"> + <xs:selector xpath="qp:map"/> + <xs:field xpath="@enumValue"/> + </xs:key> + <xs:keyref name="ExplicitImageMapSameAsKeyRef" refer="ExplicitImageMapKey"> + <xs:selector xpath="qp:mapSameAs"/> + <xs:field xpath="@targetEnumValue"/> + </xs:keyref> + </xs:element> <xs:complexType name="explicitImageMapType"> <xs:annotation> <xs:documentation>Enum values in this question type require custom mapping to image indices.</xs:documentation> </xs:annotation> <xs:complexContent> <xs:extension base="imageMapType"> - <xs:sequence> - <xs:element name="map" maxOccurs="unbounded"> + <xs:choice maxOccurs="unbounded"> + <xs:element name="map"> <xs:complexType> <xs:sequence> <xs:any namespace="http://schemas.neumont.edu/CodeGeneration/PLiX" processContents="strict" minOccurs="0"> <xs:annotation> - <xs:documentation>A custom expression. Used if the imageIndex attribute is set to .custom.</xs:documentation> + <xs:documentation>A custom expression. If the imageIndex attribute is set .custom then this expression is used directly. Otherwise, it is added to the imageIndex.</xs:documentation> </xs:annotation> </xs:any> </xs:sequence> <xs:attribute name="imageIndex" use="required"> + <xs:annotation> + <xs:documentation>An non-negative value indicating the index in the image list, or the special .custom value indicating a custom code expression.</xs:documentation> + </xs:annotation> <xs:simpleType> <xs:union memberTypes="xs:nonNegativeInteger"> <xs:simpleType> @@ -153,10 +224,28 @@ </xs:union> </xs:simpleType> </xs:attribute> - <xs:attribute name="enumValue" type="xs:token" use="required"/> + <xs:attribute name="enumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>The value from the questionType enum to associate with this image.</xs:documentation> + </xs:annotation> + </xs:attribute> </xs:complexType> </xs:element> - </xs:sequence> + <xs:element name="mapSameAs"> + <xs:complexType> + <xs:attribute name="enumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>The value from the questionType enum to associate with this image.</xs:documentation> + </xs:annotation> + </xs:attribute> + <xs:attribute name="targetEnumValue" type="xs:token" use="required"> + <xs:annotation> + <xs:documentation>This value should have the same image as the other value.</xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + </xs:element> + </xs:choice> </xs:extension> </xs:complexContent> </xs:complexType> @@ -185,6 +274,11 @@ <xs:documentation>Answers to this question are used to overlay the list of contents</xs:documentation> </xs:annotation> </xs:enumeration> + <xs:enumeration value="DisplayData"> + <xs:annotation> + <xs:documentation>Answers to this question can be used to retrieve additional display information</xs:documentation> + </xs:annotation> + </xs:enumeration> </xs:restriction> </xs:simpleType> </xs:attribute> Modified: trunk/ORMModel/Transforms/SurveyQuestionProvider.xslt =================================================================== --- trunk/ORMModel/Transforms/SurveyQuestionProvider.xslt 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/ORMModel/Transforms/SurveyQuestionProvider.xslt 2007-08-20 22:24:39 UTC (rev 1094) @@ -275,6 +275,11 @@ <plx:condition> <plx:callStatic dataTypeName="{$questionType}" name="{@enumValue}" type="field"/> </plx:condition> + <xsl:for-each select="$imageMap/qp:mapSameAs[@targetEnumValue=current()/@enumValue]"> + <plx:condition> + <plx:callStatic dataTypeName="{$questionType}" name="{@enumValue}" type="field"/> + </plx:condition> + </xsl:for-each> <plx:assign> <plx:left> <plx:nameRef name="retVal"/> @@ -285,7 +290,22 @@ <xsl:copy-of select="child::plx:*"/> </xsl:when> <xsl:otherwise> - <plx:value data="{@imageIndex}" type="i4"/> + <xsl:variable name="offset" select="child::plx:*"/> + <xsl:choose> + <xsl:when test="$offset"> + <plx:binaryOperator type="add"> + <plx:left> + <xsl:copy-of select="$offset"/> + </plx:left> + <plx:right> + <plx:value data="{@imageIndex}" type="i4"/> + </plx:right> + </plx:binaryOperator> + </xsl:when> + <xsl:otherwise> + <plx:value data="{@imageIndex}" type="i4"/> + </xsl:otherwise> + </xsl:choose> </xsl:otherwise> </xsl:choose> </plx:right> @@ -316,6 +336,65 @@ </xsl:otherwise> </xsl:choose> </plx:function> + <plx:function name="GetDisplayData" visibility="public"> + <plx:interfaceMember dataTypeName="ISurveyQuestionTypeInfo" memberName="GetDisplayData"/> + <plx:param name="answer" dataTypeName=".i4"/> + <plx:returns dataTypeName="SurveyQuestionDisplayData"/> + <xsl:if test="qp:displaySupport[@displayCategory='DisplayData']"> + <xsl:variable name="displayDataMaps" select="qp:displayDataMap/qp:displayData[(@bold='true' or @bold='1') or (@gray='true' or @gray='1')]"/> + <xsl:if test="$displayDataMaps"> + <xsl:variable name="questionType" select="string(@questionType)"/> + <plx:switch> + <plx:condition> + <plx:cast dataTypeName="{$questionType}"> + <plx:nameRef name="answer" type="parameter"/> + </plx:cast> + </plx:condition> + <xsl:for-each select="$displayDataMaps"> + <plx:case> + <plx:condition> + <plx:callStatic dataTypeName="{$questionType}" name="{@enumValue}" type="field"/> + </plx:condition> + <xsl:for-each select="../qp:displayDataSameAs[@targetEnumValue=current()/@enumValue]"> + <plx:condition> + <plx:callStatic dataTypeName="{$questionType}" name="{@enumValue}" type="field"/> + </plx:condition> + </xsl:for-each> + <plx:return> + <plx:callNew dataTypeName="SurveyQuestionDisplayData"> + <plx:passParam> + <!-- The isBold parameter --> + <xsl:choose> + <xsl:when test="@bold='true' or @bold='1'"> + <plx:trueKeyword/> + </xsl:when> + <xsl:otherwise> + <plx:falseKeyword/> + </xsl:otherwise> + </xsl:choose> + </plx:passParam> + <plx:passParam> + <!-- The isGrayText parameter --> + <xsl:choose> + <xsl:when test="@gray='true' or @gray='1'"> + <plx:trueKeyword/> + </xsl:when> + <xsl:otherwise> + <plx:falseKeyword/> + </xsl:otherwise> + </xsl:choose> + </plx:passParam> + </plx:callNew> + </plx:return> + </plx:case> + </xsl:for-each> + </plx:switch> + </xsl:if> + </xsl:if> + <plx:return> + <plx:callStatic name="Default" dataTypeName="SurveyQuestionDisplayData" type="property"/> + </plx:return> + </plx:function> <plx:property name="UISupport" visibility="public"> <plx:interfaceMember dataTypeName="ISurveyQuestionTypeInfo" memberName="UISupport"/> <plx:returns dataTypeName="SurveyQuestionUISupport"/> Modified: trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.cs =================================================================== --- trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -12,7 +12,8 @@ ProvideSurveyQuestionForSurveySchemaChildType.Instance}; private static readonly ISurveyQuestionTypeInfo[] mySurveyQuestionTypeInfo3 = new ISurveyQuestionTypeInfo[]{ ProvideSurveyQuestionForSurveyTableChildType.Instance, - ProvideSurveyQuestionForSurveyTableChildGlyphType.Instance}; + ProvideSurveyQuestionForSurveyTableChildGlyphType.Instance, + ProvideSurveyQuestionForSurveyColumnClassificationType.Instance}; private static readonly ISurveyQuestionTypeInfo[] mySurveyQuestionTypeInfo4 = new ISurveyQuestionTypeInfo[]{ ProvideSurveyQuestionForSurveyReferenceConstraintChildType.Instance}; private static readonly ISurveyQuestionTypeInfo[] mySurveyQuestionTypeInfo5 = new ISurveyQuestionTypeInfo[]{ @@ -96,6 +97,10 @@ { return answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -130,6 +135,10 @@ { return ((int)SurveySchemaType.Last + 1) + answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -164,6 +173,10 @@ { return -1; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -198,6 +211,10 @@ { return (((int)SurveySchemaType.Last + 1) + ((int)SurveySchemaChildType.Last + 1)) + answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -206,6 +223,61 @@ } } } + private sealed class ProvideSurveyQuestionForSurveyColumnClassificationType : ISurveyQuestionTypeInfo + { + private ProvideSurveyQuestionForSurveyColumnClassificationType() + { + } + public static readonly ISurveyQuestionTypeInfo Instance = new ProvideSurveyQuestionForSurveyColumnClassificationType(); + public Type QuestionType + { + get + { + return typeof(SurveyColumnClassificationType); + } + } + public int AskQuestion(object data) + { + IAnswerSurveyQuestion<SurveyColumnClassificationType> typedData = data as IAnswerSurveyQuestion<SurveyColumnClassificationType>; + if (typedData != null) + { + return typedData.AskQuestion(); + } + return -1; + } + public int MapAnswerToImageIndex(int answer) + { + int retVal; + switch ((SurveyColumnClassificationType)answer) + { + case SurveyColumnClassificationType.PrimaryRequired: + case SurveyColumnClassificationType.PrimaryNullable: + retVal = ((((((int)SurveySchemaType.Last + 1) + ((int)SurveySchemaChildType.Last + 1)) + ((int)SurveyTableChildGlyphType.Last + 1)) + ((int)SurveyReferenceConstraintChildType.Last + 1)) + ((int)SurveyUniquenessConstraintChildType.Last + 1)) + 0; + break; + default: + retVal = -1; + break; + } + return retVal; + } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + switch ((SurveyColumnClassificationType)answer) + { + case SurveyColumnClassificationType.Required: + case SurveyColumnClassificationType.PrimaryRequired: + return new SurveyQuestionDisplayData(true, false); + } + return SurveyQuestionDisplayData.Default; + } + public SurveyQuestionUISupport UISupport + { + get + { + return SurveyQuestionUISupport.Overlay | SurveyQuestionUISupport.DisplayData; + } + } + } private sealed class ProvideSurveyQuestionForSurveyReferenceConstraintChildType : ISurveyQuestionTypeInfo { private ProvideSurveyQuestionForSurveyReferenceConstraintChildType() @@ -232,6 +304,10 @@ { return ((((int)SurveySchemaType.Last + 1) + ((int)SurveySchemaChildType.Last + 1)) + ((int)SurveyTableChildGlyphType.Last + 1)) + answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get @@ -266,6 +342,10 @@ { return (((((int)SurveySchemaType.Last + 1) + ((int)SurveySchemaChildType.Last + 1)) + ((int)SurveyTableChildGlyphType.Last + 1)) + ((int)SurveyReferenceConstraintChildType.Last + 1)) + answer; } + public SurveyQuestionDisplayData GetDisplayData(int answer) + { + return SurveyQuestionDisplayData.Default; + } public SurveyQuestionUISupport UISupport { get Modified: trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.xml =================================================================== --- trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.xml 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/RelationalModel/DcilModel/DcilModel.SurveyQuestionProvider.xml 2007-08-20 22:24:39 UTC (rev 1094) @@ -63,6 +63,93 @@ </qp:offset> </qp:sequentialImageMap> </qp:surveyQuestion> + <qp:surveyQuestion questionType="SurveyColumnClassificationType"> + <qp:displaySupport displayCategory="Overlay"/> + <qp:displaySupport displayCategory="DisplayData"/> + <qp:explicitImageMap> + <qp:map enumValue="PrimaryRequired" imageIndex="0"> + <plx:binaryOperator type="add"> + <plx:left> + <plx:binaryOperator type="add"> + <plx:left> + <plx:binaryOperator type="add"> + <plx:left> + <plx:binaryOperator type="add"> + <plx:left> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveySchemaType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:left> + <plx:right> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveySchemaChildType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:right> + </plx:binaryOperator> + </plx:left> + <plx:right> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveyTableChildGlyphType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:right> + </plx:binaryOperator> + </plx:left> + <plx:right> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveyReferenceConstraintChildType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:right> + </plx:binaryOperator> + </plx:left> + <plx:right> + <plx:binaryOperator type="add"> + <plx:left> + <plx:cast dataTypeName=".i4"> + <plx:callStatic dataTypeName="SurveyUniquenessConstraintChildType" name="Last" type="field"/> + </plx:cast> + </plx:left> + <plx:right> + <plx:value data="1" type="i4"/> + </plx:right> + </plx:binaryOperator> + </plx:right> + </plx:binaryOperator> + </qp:map> + <qp:mapSameAs enumValue="PrimaryNullable" targetEnumValue="PrimaryRequired"/> + </qp:explicitImageMap> + <qp:displayDataMap> + <qp:displayData enumValue="Required" bold="true"/> + <qp:displayDataSameAs enumValue="PrimaryRequired" targetEnumValue="Required"/> + </qp:displayDataMap> + </qp:surveyQuestion> <qp:surveyQuestion questionType="SurveyReferenceConstraintChildType"> <qp:displaySupport displayCategory="Sorting"/> <qp:displaySupport displayCategory="Glyph"/> @@ -196,6 +283,7 @@ </qp:expansionKey> <qp:surveyQuestion ref="SurveyTableChildType"/> <qp:surveyQuestion ref="SurveyTableChildGlyphType"/> + <qp:surveyQuestion ref="SurveyColumnClassificationType"/> </qp:grouping> <qp:grouping> <qp:expansionKey> Modified: trunk/RelationalModel/DcilModel/Resources/SurveyTree.ImageStrip.png =================================================================== (Binary files differ) Modified: trunk/RelationalModel/DcilModel/SurveyImplementations/SurveyQuestions.cs =================================================================== --- trunk/RelationalModel/DcilModel/SurveyImplementations/SurveyQuestions.cs 2007-08-20 22:18:31 UTC (rev 1093) +++ trunk/RelationalModel/DcilModel/SurveyImplementations/SurveyQuestions.cs 2007-08-20 22:24:39 UTC (rev 1094) @@ -109,6 +109,32 @@ Last = PrimaryUniquenessConstraint, } /// <summary> + /// The list of possible answers to the ColumnNullableType category in the model browser + /// </summary> + public enum SurveyColumnClassificationType + { + /// <summary> + /// The column is required + /// </summary> + Required, + /// <summary> + /// The column is primary and required + /// </summary> + PrimaryRequired, + /// <summary> + /// The column is nullable + /// </summary> + Nullable, + /// <summary> + /// The column is primary and nullable + /// </summary> + PrimaryNullable, + /// <summary> + /// The current highest-valued value in the enumeration + /// </summary> + Last = PrimaryNullable, + } + /// <summary> /// The list of possible answers for the ReferenceConstraintChildType grouping in the model browser /// </summary> [TypeConverter(typeof(EnumConverter<SurveyReferenceConstraintChildType, Catalog>))] @@ -382,7 +408,7 @@ } #endregion // Table answers #region Column answers - partial class Column : IAnswerSurveyQuestion<SurveyTableChildType>, IAnswerSurveyQuestion<SurveyTableChildGlyphType>, ISurveyNode + partial class Column : IAnswerSurveyQuestion<SurveyTableChildType>, IAnswerSurveyQuestion<SurveyTableChildGlyphType>, IAnswerSurveyQuestion<SurveyColumnClassificationType>, ISurveyNode, ICustomComparableSurveyNode { #region IAnswerSurveyQuestion<SurveyTableChildType> Implementation int IAnswerSurveyQuestion<SurveyTableChildType>.AskQuestion() @@ -410,6 +436,21 @@ return (int)SurveyTableChildGlyphType.Column; } #endregion // IAnswerSurveyQuestion<SurveyTableChildGlyphType> Implementation + #region IAnswerSurveyQuestion<SurveyColumnClassificationType> Implementation + int IAnswerSurveyQuestion<SurveyColumnClassificationType>.AskQuestion() + { + return AskElementQuestionForClassification(); + } + /// <summary> + /// implementation of AskQuestion method from IAnswerSurveyQuestion + /// </summary> + protected int AskElementQuestionForClassification() + { + return (int)(IsPartOfPrimaryIdentifier ? + IsNullable ? SurveyColumnClassificationType.PrimaryNullable : SurveyColumnClassificationType.PrimaryRequired : + IsNullable ? SurveyColumnClassificationType.Nullable : SurveyColumnClassificationType.Required); + } + #endregion // IAnswerSurveyQuestion<SurveyTableChildGlyphType> Implementation #region ISurveyNode Implementation bool ISurveyNode.IsSurveyNameEditable { @@ -507,6 +548,48 @@ } } #endregion // ISurveyNode Implementation + #region ICustomComparableSurveyNode Implementation + int ICustomComparableSurveyNode.CompareToSurveyNode(object other) + { + return CompareToSurveyNode(other); + } + /// <summary> + /// Implements <see cref="ICustomComparableSurveyNode.CompareToSurveyNode"/>. Columns + /// sort with columns in the preferred identifier first. + /// </summary> + protected int CompareToSurveyNode(object other) + { + Column otherColumn = other as Column; + if (otherColumn != null) + { + bool leftIsPrimary = this.IsPartOfPrimaryIdentifier; + bool rightIsPrimary = otherColumn.IsPartOfPrimaryIdentifier; + if (leftIsPrimary ^ rightIsPrimary) + { + return leftIsPrimary ? -1 : 1; + } + } + // For this comparison, 0 implies no information is available + return 0; + } + /// <summary> + /// Is this column part of the primary identification scheme? + /// </summary> + private bool IsPartOfPrimaryIdentifier + { + get + { + foreach (UniquenessConstraint constraint in UniquenessConstraintIncludesColumn.GetUniquenessConstraints(this)) + { + if (constraint.IsPrimary) + { + return true; + } + } + return false; + } + } + #endregion // ICustomComparableSurveyNode Implementation } #endregion // Column answers #region ReferenceConstraint answers @@ -1248,6 +1331,8 @@ eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementPropertyChangedEventArgs>(TableChanged), action); // Column, uniqueness, and foreign key elements (inside table) + // UNDONE: This does not handle updates to the primary identifier keys and sort order. + // There are currently no incremental updates involving primary keys. eventManager.AddOrRemoveHandler(dataDir.FindDomainRelationship(TableContainsColumn.DomainClassId), new EventHandler<ElementAddedEventArgs>(ColumnAdded), action); classInfo = dataDir.FindDomainClass(Column.DomainClassId); eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(ElementRemoved), action); @@ -1280,6 +1365,7 @@ #endregion // IModelingEventSubscriber Implementation #region SurveyQuestion event handlers private static readonly Type[] SurveyTableChildGlyphTypeQuestionTypes = new Type[] { typeof(SurveyTableChildGlyphType) }; + private static readonly Type[] SurveyColumnClassificationTypeQuestionTypes = new Type[] { typeof(SurveyColumnClassificationType) }; /// <summary> /// This will work for almost all delete scenarios /// </summary> @@ -1351,11 +1437,12 @@ } private static void ColumnChanged(object sender, ElementPropertyChangedEventArgs e) { - if (e.DomainProperty.Id == Column.NameDomainPropertyId) + INotifySurveyElementChanged eventNotify; + ModelElement element = e.ModelElement; + if (null != (eventNotify = (element.Store as IORMToolServices).NotifySurveyElementChanged)) { - INotifySurveyElementChanged eventNotify; - ModelElement element = e.ModelElement; - if (null != (eventNotify = (element.Store as IORMToolServices).NotifySurveyElementChanged)) + Guid attributeId = e.DomainProperty.Id; + if (attributeId == Column.NameDomainPropertyId) { eventNotify.ElementRenamed(element); Column column = (Column)element; @@ -1372,6 +1459,10 @@ eventNotify.ElementRenamed(columnRef); } } + else if (attributeId == Column.IsNullableDomainPropertyId) + { + eventNotify.ElementChanged(e.ModelElement, SurveyColumnClassificationTypeQuestionTypes); + } } } private static void ReferenceConstraintAdded(object sender, ElementAddedEventArgs e) @@ -1440,7 +1531,7 @@ } else if (attributeId == UniquenessConstraint.IsPrimaryDomainPropertyId) { - eventNotify.ElementChanged(element, ConceptualDatabaseDomainModel.SurveyTableChildGlyphTypeQuestionTypes); + eventNotify.ElementChanged(element, SurveyTableChildGlyphTypeQuestionTypes); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |