From: <mcu...@us...> - 2008-11-18 19:57:27
|
Revision: 1335 http://orm.svn.sourceforge.net/orm/?rev=1335&view=rev Author: mcurland Date: 2008-11-18 19:57:24 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Selecting the context window is causing a phantom 'New Page' diagram to appear in the model browser and diagram spy windows. We need to ignore any diagrams that are not in the default partition. refs #376 refs #377 Modified Paths: -------------- trunk/ORMModel/Shell/DiagramSurvey.cs trunk/ORMModel/Shell/ORMDiagramSpy.cs Modified: trunk/ORMModel/Shell/DiagramSurvey.cs =================================================================== --- trunk/ORMModel/Shell/DiagramSurvey.cs 2008-11-18 10:12:46 UTC (rev 1334) +++ trunk/ORMModel/Shell/DiagramSurvey.cs 2008-11-18 19:57:24 UTC (rev 1335) @@ -176,11 +176,16 @@ if (expansionKey == null) { Dictionary<Diagram, DiagramNode> diagramToNodeMap = myDiagramToNodeMap ?? (myDiagramToNodeMap = new Dictionary<Diagram, DiagramNode>()); + Store store = Store; + Partition defaultPartition = store.DefaultPartition; foreach (Diagram diagram in Store.ElementDirectory.FindElements<Diagram>(true)) { - DiagramNode node = new DiagramNode(diagram); - diagramToNodeMap.Add(diagram, node); - yield return node; + if (diagram.Partition == defaultPartition) + { + DiagramNode node = new DiagramNode(diagram); + diagramToNodeMap.Add(diagram, node); + yield return node; + } } } } @@ -213,7 +218,10 @@ { INotifySurveyElementChanged eventNotify; ModelElement element = e.ModelElement; - if (!element.IsDeleted && null != (eventNotify = (element.Store as IORMToolServices).NotifySurveyElementChanged)) + Store store; + if (!element.IsDeleted && + (store = element.Store).DefaultPartition == element.Partition && + null != (eventNotify = (store as IORMToolServices).NotifySurveyElementChanged)) { Diagram diagram = (Diagram)element; DiagramNode node = new DiagramNode(diagram); @@ -228,8 +236,10 @@ Dictionary<Diagram, DiagramNode> nodeMap; DiagramNode node; Diagram diagram; + Store store; if (null != (nodeMap = myDiagramToNodeMap) && - null != (eventNotify = (element.Store as IORMToolServices).NotifySurveyElementChanged) && + (store = element.Store).DefaultPartition == element.Partition && + null != (eventNotify = (store as IORMToolServices).NotifySurveyElementChanged) && nodeMap.TryGetValue(diagram = (Diagram)element, out node)) { nodeMap.Remove(diagram); @@ -242,9 +252,11 @@ ModelElement element = e.ModelElement; Dictionary<Diagram, DiagramNode> nodeMap; DiagramNode node; + Store store; if (!element.IsDeleted && null != (nodeMap = myDiagramToNodeMap) && - null != (eventNotify = (element.Store as IORMToolServices).NotifySurveyElementChanged) && + (store = element.Store).DefaultPartition == element.Partition && + null != (eventNotify = (store as IORMToolServices).NotifySurveyElementChanged) && nodeMap.TryGetValue((Diagram)element, out node)) { eventNotify.ElementRenamed(node); Modified: trunk/ORMModel/Shell/ORMDiagramSpy.cs =================================================================== --- trunk/ORMModel/Shell/ORMDiagramSpy.cs 2008-11-18 10:12:46 UTC (rev 1334) +++ trunk/ORMModel/Shell/ORMDiagramSpy.cs 2008-11-18 19:57:24 UTC (rev 1335) @@ -222,15 +222,23 @@ } private void DiagramAddedEvent(object sender, ElementAddedEventArgs e) { - myDiagramSetChanged = true; + ModelElement element = e.ModelElement; + if (element.Store.DefaultPartition == element.Partition) + { + myDiagramSetChanged = true; + } } private void DiagramRemovedEvent(object sender, ElementDeletedEventArgs e) { - myDiagramSetChanged = true; - if (e.ModelElement == myDiagramView.Diagram) + ModelElement element = e.ModelElement; + if (element.Store.DefaultPartition == element.Partition) { - // Note that this is unlikely, the diagram will be disassociatin firts - AdjustVisibility(false, true); + myDiagramSetChanged = true; + if (element == myDiagramView.Diagram) + { + // Note that this is unlikely, the diagram will be disassociatin firts + AdjustVisibility(false, true); + } } } private void Disassociate() @@ -261,7 +269,11 @@ } private void DiagramNameChangedEvent(object sender, ElementPropertyChangedEventArgs e) { - myDiagramSetChanged = true; + ModelElement element = e.ModelElement; + if (element.Store.DefaultPartition == element.Partition) + { + myDiagramSetChanged = true; + } } private void ElementEventsEnded(object sender, ElementEventsEndedEventArgs e) { @@ -323,32 +335,61 @@ { Diagram[] diagramArray = new Diagram[diagramCount]; diagrams.CopyTo(diagramArray, 0); + Partition targetPartition = store.DefaultPartition; Array.Sort<Diagram>( diagramArray, delegate(Diagram left, Diagram right) { + // Filter diagrams, such as the context window, that are not in the default partition + if (left.Partition != targetPartition) + { + if (right.Partition == targetPartition) + { + return 1; + } + } + else if (right.Partition != targetPartition) + { + return -1; + } return string.Compare(left.Name, right.Name, StringComparison.CurrentCultureIgnoreCase); }); - StringBuilder builder = new StringBuilder(ResourceStrings.DiagramSpyDiagramListStart); - string listSeparator = CultureInfo.CurrentCulture.TextInfo.ListSeparator + " "; - int separatorLength = listSeparator.Length; - int offset = builder.Length; - links.Clear(); - for (int i = 0; i < diagramCount; ++i) + for (int i = diagramCount - 1; i >= 0; --i) { - Diagram diagram = diagramArray[i]; - string diagramName = diagram.Name; - int nameLength = diagramName.Length; - if (i != 0) + if (diagramArray[i].Partition == targetPartition) { - offset += separatorLength; - builder.Append(listSeparator); + break; } - builder.Append(diagramName); - links.Add(offset, nameLength, diagram); - offset += nameLength; + --diagramCount; } - watermarkLabel.Text = builder.ToString(); + if (diagramCount == 0) + { + watermarkLabel.Text = ResourceStrings.DiagramSpyNoSelection; + links.Clear(); + } + else + { + StringBuilder builder = new StringBuilder(ResourceStrings.DiagramSpyDiagramListStart); + string listSeparator = CultureInfo.CurrentCulture.TextInfo.ListSeparator + " "; + int separatorLength = listSeparator.Length; + int offset = builder.Length; + links.Clear(); + for (int i = 0; i < diagramCount; ++i) + { + Diagram diagram = diagramArray[i]; + string diagramName = diagram.Name; + int nameLength = diagramName.Length; + if (i != 0) + { + offset += separatorLength; + builder.Append(listSeparator); + } + builder.Append(diagramName); + links.Add(offset, nameLength, diagram); + offset += nameLength; + } + watermarkLabel.Text = builder.ToString(); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |