From: <mcu...@us...> - 2009-09-05 17:25:27
|
Revision: 1406 http://orm.svn.sourceforge.net/orm/?rev=1406&view=rev Author: mcurland Date: 2009-09-05 17:25:17 +0000 (Sat, 05 Sep 2009) Log Message: ----------- * Fix selection issue when adding secondary readings in the same order in the reading editor. * Enable F2 activation of inplace editors for reading extension properties. refs #397 * Workaround tree control navigation issues with complex subitems (Right arrow not working correctly if no column permutation specified, fix previous workaround bug with down arrow) Modified Paths: -------------- trunk/ORMModel/Framework/Shell/StandardMultiColumnTree.cs trunk/ORMModel/Resources/ResourceStringsGenerator.cs trunk/ORMModel/Resources/ResourceStringsGenerator.xml trunk/ORMModel/ShapeModel/ORMDiagram.resx trunk/ORMModel/Shell/ORMReadingEditor.cs trunk/ORMModel/Shell/ReadingEditor.cs Modified: trunk/ORMModel/Framework/Shell/StandardMultiColumnTree.cs =================================================================== --- trunk/ORMModel/Framework/Shell/StandardMultiColumnTree.cs 2009-08-26 19:32:11 UTC (rev 1405) +++ trunk/ORMModel/Framework/Shell/StandardMultiColumnTree.cs 2009-09-05 17:25:17 UTC (rev 1406) @@ -68,10 +68,11 @@ // UNDONE: MSBUG GetNavigationTarget calls the internal method to get its blank expansion, not // the interface, so we have no way to override it. Duplicate the GetNavigationTarget fix here for // the 'Down' navigation target. + BlankExpansionData blankExpansion; switch (direction) { case TreeNavigation.Down: - BlankExpansionData blankExpansion = GetBlankExpansion(sourceRow, sourceColumn, columnPermutation); + blankExpansion = GetBlankExpansion(sourceRow, sourceColumn, columnPermutation); if (blankExpansion.Anchor.IsValid) { int lastRow = ((ITree)this).VisibleItemCount - 1; @@ -87,11 +88,30 @@ int topRow = blankExpansion.TopRow; if (sourceColumn == blankExpansion.AnchorColumn && topRow >= testRow) { - return new VirtualTreeCoordinate(topRow, (columnPermutation != null) ? columnPermutation.GetPermutedColumn(sourceColumn) : sourceColumn); + return new VirtualTreeCoordinate(topRow, sourceColumn); } } } return VirtualTreeCoordinate.Invalid; + case TreeNavigation.Right: + // If no column permutation is specified and we're on the first row in a complex + // subitem expansion, then the provided implementation does not go right. + // MSBUG: VirtualTree.GetNavigationTarget is looking at the column count of the + // ParentNode of a complex subitem. The column count in this case is always 1. + if (columnPermutation == null) + { + VirtualTreeCoordinate retVal = base.GetNavigationTarget(TreeNavigation.Right, sourceRow, sourceColumn, null); + int lastAllowedSourceColumn; + if (!retVal.IsValid && + sourceColumn < (lastAllowedSourceColumn = (ColumnCount - 1)) && + (blankExpansion = GetBlankExpansion(sourceRow, sourceColumn, null)).Anchor.IsValid && + blankExpansion.RightColumn < lastAllowedSourceColumn) + { + retVal = GetBlankExpansion(sourceRow, blankExpansion.RightColumn + 1, null).Anchor; + } + return retVal; + } + break; case TreeNavigation.LeftColumn: if (sourceColumn == 0) { Modified: trunk/ORMModel/Resources/ResourceStringsGenerator.cs =================================================================== --- trunk/ORMModel/Resources/ResourceStringsGenerator.cs 2009-08-26 19:32:11 UTC (rev 1405) +++ trunk/ORMModel/Resources/ResourceStringsGenerator.cs 2009-09-05 17:25:17 UTC (rev 1406) @@ -1501,14 +1501,6 @@ return ResourceStrings.GetString(ResourceManagers.Diagram, "Command.DeleteReading.Text"); } } - /// <summary>This text appears on the undo/redo menu when a reading is edited.</summary> - public static string CommandEditReadingText - { - get - { - return ResourceStrings.GetString(ResourceManagers.Diagram, "Command.EditReading.Text"); - } - } /// <summary>This text appears on the move role left/right when the fact type is binary.</summary> public static string CommandSwapRoleOrderText { Modified: trunk/ORMModel/Resources/ResourceStringsGenerator.xml =================================================================== --- trunk/ORMModel/Resources/ResourceStringsGenerator.xml 2009-08-26 19:32:11 UTC (rev 1405) +++ trunk/ORMModel/Resources/ResourceStringsGenerator.xml 2009-09-05 17:25:17 UTC (rev 1406) @@ -237,7 +237,6 @@ <ResourceString name="CommandDeleteMultipleShapeText" model="Diagram" resourceName="Command.DeleteMultipleShape.Text"/> <ResourceString name="CommandDeleteRoleText" model="Diagram" resourceName="Command.DeleteRole.Text"/> <ResourceString name="CommandDeleteReadingText" model="Diagram" resourceName="Command.DeleteReading.Text"/> - <ResourceString name="CommandEditReadingText" model="Diagram" resourceName="Command.EditReading.Text"/> <ResourceString name="CommandSwapRoleOrderText" model="Diagram" resourceName="Command.SwapRoleOrder.Text"/> <ResourceString name="CommandNextOnThisDiagramText" model="Diagram" resourceName="Command.NextOnThisDiagram.Text"/> <ResourceString name="DiagramSpyWindowTitle" model="Diagram" resourceName="DiagramSpy.WindowTitle"/> Modified: trunk/ORMModel/ShapeModel/ORMDiagram.resx =================================================================== --- trunk/ORMModel/ShapeModel/ORMDiagram.resx 2009-08-26 19:32:11 UTC (rev 1405) +++ trunk/ORMModel/ShapeModel/ORMDiagram.resx 2009-09-05 17:25:17 UTC (rev 1406) @@ -203,10 +203,6 @@ <value xml:space="preserve">Delete Reading</value> <comment xml:space="preserve">This text appears on the undo/redo menu when a reading is deleted.</comment> </data> - <data name="Command.EditReading.Text"> - <value xml:space="preserve">Edit Reading</value> - <comment xml:space="preserve">This text appears on the undo/redo menu when a reading is edited.</comment> - </data> <data name="Command.NextOnThisDiagram.Text"> <value xml:space="preserve">Next on this Dia&gram</value> <comment xml:space="preserve">This text appears on the 'Select on Diagram' menu if there is more than one shape for the selected element on the current diagram.</comment> Modified: trunk/ORMModel/Shell/ORMReadingEditor.cs =================================================================== --- trunk/ORMModel/Shell/ORMReadingEditor.cs 2009-08-26 19:32:11 UTC (rev 1405) +++ trunk/ORMModel/Shell/ORMReadingEditor.cs 2009-09-05 17:25:17 UTC (rev 1406) @@ -383,16 +383,6 @@ { myReadingEditor.ActivateReading(fact); } - - public void DeleteSelectedReading() - { - myReadingEditor.OnMenuDeleteSelectedReading(); - } - - public void EditSelectedReading() - { - myReadingEditor.EditSelectedReading(); - } #endregion // Reading activation helper } #endregion @@ -575,7 +565,7 @@ return QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); } [DllImport("user32.dll", CharSet = CharSet.Auto)] - private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam); + private static extern IntPtr SendMessage(HandleRef hWnd, int msg, int wParam, int lParam); /// <summary> /// Provides a first chance to handle any command that MSOLE.IOleCommandTarget.QueryStatus /// informed the shell to pass to this window. Implements IOleCommandTarget.Exec @@ -657,7 +647,7 @@ { if (editor.IsReadingPaneActive && editor.CurrentReading != null) { - form.DeleteSelectedReading(); + editor.OnMenuDeleteSelectedReading(); } } else @@ -665,7 +655,7 @@ Control editControl = editor.LabelEditControl; if (editControl != null) { - IntPtr editHandle = editControl.Handle; + HandleRef editHandle = new HandleRef(editControl, editControl.Handle); // WM_KEYDOWN == 0x100 SendMessage(editHandle, 0x100, (int)Keys.Delete, 1); // WM_KEYUP == 0x101 @@ -686,13 +676,25 @@ // VirtualTreeView control), handle the edit command and set the hresult to a handled status. if (!editor.EditingFactType.IsEmpty) { - if (editor.CurrentReading != null) + if (!editor.InLabelEdit) { if (editor.IsReadingPaneActive) { - form.EditSelectedReading(); + editor.EditSelection(); } } + else + { + Control editControl = editor.LabelEditControl; + if (editControl != null) + { + HandleRef editHandle = new HandleRef(editControl, editControl.Handle); + // WM_KEYDOWN == 0x100 + SendMessage(editHandle, 0x100, (int)Keys.F2, 1); + // WM_KEYUP == 0x101 + SendMessage(editHandle, 0x101, (int)Keys.F2, 0x40000001); + } + } } // We enabled the command, so we say we handled it regardless of the further conditions hr = VSConstants.S_OK; Modified: trunk/ORMModel/Shell/ReadingEditor.cs =================================================================== --- trunk/ORMModel/Shell/ReadingEditor.cs 2009-08-26 19:32:11 UTC (rev 1405) +++ trunk/ORMModel/Shell/ReadingEditor.cs 2009-09-05 17:25:17 UTC (rev 1406) @@ -665,7 +665,6 @@ private abstract class RootBranch : BaseBranch { #region Virtual and Abstract Methods - public abstract bool IsAdding { get; } public virtual ReadingEditorCommands SupportedSelectionCommands(int itemLocation) { return ReadingEditorCommands.None; @@ -1249,14 +1248,11 @@ } } /// <summary> - /// Puts the reading that is currently selected in the reading order into edit mode. + /// Puts the currently selected item into edit mode. /// </summary> - public void EditSelectedReading() + public void EditSelection() { - using (Transaction t = myFactType.Store.TransactionManager.BeginTransaction(ResourceStrings.CommandEditReadingText)) - { - vtrReadings.BeginLabelEdit(); - } + vtrReadings.BeginLabelEdit(); } #endregion // Reading activation helper @@ -1847,15 +1843,6 @@ } #endregion // Reading Methods #region ReadingOrder Methods - public override bool IsAdding - { - get - { - ReadingOrderBranch testBranch; - return (null != (testBranch = myReadingOrderBranch) && testBranch.IsAdding) || - (null != (testBranch = myImpliedFactTypeBranch) && testBranch.IsAdding); - } - } public override void EditReadingOrder(IList<RoleBase> collection) { FactType matchFactType = collection[0].FactType; @@ -1895,7 +1882,6 @@ private ReadingOrderInformationCollection myReadingOrderPermutations; private readonly IList<RoleBase> myRoleDisplayOrder; private string[] myRoleNames; - private int myInsertedRow = -1; private BranchModificationEventHandler myModify; private ReadingEditor myEditor; #endregion // Member Variables @@ -1988,25 +1974,15 @@ string newReadingText = editor.BuildReadingText(); if (newReadingText.Length != 0) { - Reading theNewReading; - try + using (Transaction t = store.TransactionManager.BeginTransaction(ResourceStrings.ModelReadingEditorNewReadingTransactionText)) { - myInsertedRow = row; - using (Transaction t = store.TransactionManager.BeginTransaction(ResourceStrings.ModelReadingEditorNewReadingTransactionText)) - { - ReadingOrder theOrder = myFactType.EnsureReadingOrder(myReadingOrderKeyedCollection[row].RoleOrder); - Debug.Assert(theOrder != null, "A ReadingOrder should have been found or created."); - theNewReading = new Reading(store); - LinkedElementCollection<Reading> readings = theOrder.ReadingCollection; - readings.Add(theNewReading); - theNewReading.Text = newReadingText; - t.Commit(); - } + ReadingOrder readingOrder = myFactType.EnsureReadingOrder(myReadingOrderKeyedCollection[row].RoleOrder); + Debug.Assert(readingOrder != null, "A ReadingOrder should have been found or created."); + Reading newReading = new Reading(store); + newReading.ReadingOrder = readingOrder; + newReading.Text = newReadingText; + t.Commit(); } - finally - { - myInsertedRow = -1; - } return LabelEditResult.AcceptEdit; } return LabelEditResult.CancelEdit; @@ -2307,16 +2283,6 @@ } #endregion // Reading Branch Methods #region ReadingOrder Branch Methods - /// <summary> - /// Used to find out if the branch is in the process of adding a new entry from input into the branch. - /// </summary> - public override bool IsAdding - { - get - { - return myInsertedRow != -1; - } - } public override void AddNewReadingOrder() { VirtualTreeControl control = ReadingEditor.Instance.TreeControl; @@ -3030,7 +2996,6 @@ private readonly ReadingEditor myEditor; private ExtensionPropertyBranch[] myPropertyBranches; private bool myShowNewRow; - private int myInsertedRow = -1; private BranchModificationEventHandler myModify; #endregion // Member Variables #region Constructor @@ -3085,23 +3050,23 @@ string newReadingText = editor.BuildReadingText(); if (newReadingText.Length != 0) { - try + Reading newReading = null; + using (Transaction t = store.TransactionManager.BeginTransaction(ResourceStrings.ModelReadingEditorNewReadingTransactionText)) { - myInsertedRow = row; - using (Transaction t = store.TransactionManager.BeginTransaction(ResourceStrings.ModelReadingEditorNewReadingTransactionText)) - { - Debug.Assert(myReadingOrder != null, "A ReadingOrder should have been found or created."); - this.ShowNewRow(false); - Reading theNewReading = new Reading(store); - LinkedElementCollection<Reading> readings = myReadingOrder.ReadingCollection; - readings.Add(theNewReading); - theNewReading.Text = newReadingText; - t.Commit(); - } + Debug.Assert(myReadingOrder != null, "A ReadingOrder should have been found or created."); + this.ShowNewRow(false); + newReading = new Reading(store); + newReading.ReadingOrder = myReadingOrder; + newReading.Text = newReadingText; + t.Commit(); } - finally + if (newReading != null) { - myInsertedRow = -1; + // Reselect the new reading. The option to this approach is to + // replace the new row with the reading before the transaction + // commits so that the row is not inserted/readded. For the same + // user experience, this isn't worth the additional complication. + myEditor.TreeControl.SelectObject(null, newReading, (int)ObjectStyle.TrackingObject, 0); } return LabelEditResult.AcceptEdit; } @@ -3216,17 +3181,6 @@ } } /// <summary> - /// Used to find out if the branch is in the process of adding a new entry from - /// input into the branch. - /// </summary> - public bool IsAdding - { - get - { - return myInsertedRow != -1; - } - } - /// <summary> /// Displays the new row for adding a reading to the reading order /// </summary> public void ShowNewRow(bool show) @@ -3241,10 +3195,6 @@ // Notify addition at the end int insertPosition = myReadings.Count - 2; modify(this, BranchModificationEventArgs.InsertItems(this, insertPosition, 1)); - foreach (ExtensionPropertyBranch propertyBranch in ExtensionPropertyBranches) - { - modify(propertyBranch, BranchModificationEventArgs.InsertItems(propertyBranch, insertPosition, 1)); - } } } else if (myShowNewRow && !show) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |