From: <mcu...@us...> - 2008-11-21 17:40:44
|
Revision: 1340 http://orm.svn.sourceforge.net/orm/?rev=1340&view=rev Author: mcurland Date: 2008-11-21 17:40:41 +0000 (Fri, 21 Nov 2008) Log Message: ----------- Pressing F2 (the View.EditLabel command) while an in-place edit control was already active disabled the command. Always handle this command to stop it disabling. refs #374 Modified Paths: -------------- trunk/ORMModel/Shell/ORMModelBrowser.cs trunk/ORMModel/Shell/ORMModelBrowserCommandSet.cs trunk/ORMModel/Shell/ORMReadingEditor.cs trunk/ORMModel/Shell/ORMSamplePopulationToolWindow.cs Modified: trunk/ORMModel/Shell/ORMModelBrowser.cs =================================================================== --- trunk/ORMModel/Shell/ORMModelBrowser.cs 2008-11-20 08:17:47 UTC (rev 1339) +++ trunk/ORMModel/Shell/ORMModelBrowser.cs 2008-11-21 17:40:41 UTC (rev 1340) @@ -218,7 +218,12 @@ /// </summary> protected virtual void OnMenuEditLabel() { - myTreeContainer.TreeControl.BeginLabelEdit(); + // We always report an enabled status on this, so verify that it + // is actually enabled before handling it. + if (0 != (myEnabledCommands & ORMDesignerCommands.EditLabel)) + { + myTreeContainer.TreeControl.BeginLabelEdit(); + } } /// <summary> /// Select the specified shape in the specified target window. Modified: trunk/ORMModel/Shell/ORMModelBrowserCommandSet.cs =================================================================== --- trunk/ORMModel/Shell/ORMModelBrowserCommandSet.cs 2008-11-20 08:17:47 UTC (rev 1339) +++ trunk/ORMModel/Shell/ORMModelBrowserCommandSet.cs 2008-11-21 17:40:41 UTC (rev 1340) @@ -166,7 +166,16 @@ } public void OnStatusEditLabel(Object sender, EventArgs e) { - ORMModelBrowserToolWindow.OnStatusCommand(sender, ORMDesignerCommands.EditLabel, CurrentToolWindow); + MenuCommand command = sender as MenuCommand; + if (command != null) + { + // Support this command regardless of whether or not it is supported by the current + // element or the current state of the inline editor. If we do not do this, then an F2 + // keypress with an editor already open will report the command as disabled and we would + // need to use IVsUIShell.UpdateCommandUI whenever an editor closed to reenable the command. + command.Visible = true; + command.Enabled = true; + } } public void OnMenuEditLabel(Object sender, EventArgs e) { Modified: trunk/ORMModel/Shell/ORMReadingEditor.cs =================================================================== --- trunk/ORMModel/Shell/ORMReadingEditor.cs 2008-11-20 08:17:47 UTC (rev 1339) +++ trunk/ORMModel/Shell/ORMReadingEditor.cs 2008-11-21 17:40:41 UTC (rev 1340) @@ -420,16 +420,12 @@ break; case VSConstants.VSStd97CmdID.EditLabel: - // Inform the shell that we should have a chance to handle the edit label (rename) command. - if (!this.myForm.ReadingEditor.EditingFactType.IsEmpty) - { - cmd.cmdf = (int)(MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED); - prgCmds[0] = cmd; - } - else - { - goto default; - } + // Support this command regardless of the current state of the inline editor. + // If we do not do this, then an F2 keypress with an editor already open will + // report the command as disabled and we would need to use IVsUIShell.UpdateCommandUI + // whenever an editor closed to reenable the command. + cmd.cmdf = (int)(MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED); + prgCmds[0] = cmd; break; default: @@ -528,13 +524,9 @@ myForm.EditSelectedReading(); } } - // We enabled the command, so we say we handled it regardless of the further conditions - hr = VSConstants.S_OK; } - else - { - goto default; - } + // We enabled the command, so we say we handled it regardless of the further conditions + hr = VSConstants.S_OK; break; default: Modified: trunk/ORMModel/Shell/ORMSamplePopulationToolWindow.cs =================================================================== --- trunk/ORMModel/Shell/ORMSamplePopulationToolWindow.cs 2008-11-20 08:17:47 UTC (rev 1339) +++ trunk/ORMModel/Shell/ORMSamplePopulationToolWindow.cs 2008-11-21 17:40:41 UTC (rev 1340) @@ -374,16 +374,12 @@ } break; case VSConstants.VSStd97CmdID.EditLabel: - // Inform the shell that we should have a chance to handle the edit command - if (!this.myEditor.FullRowSelect && !this.myEditor.InLabelEdit) - { - cmd.cmdf = (int)(MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED); - prgCmds[0] = cmd; - } - else - { - goto default; - } + // Support this command regardless of the current state of the inline editor. + // If we do not do this, then an F2 keypress with an editor already open will + // report the command as disabled and we would need to use IVsUIShell.UpdateCommandUI + // whenever an editor closed to reenable the command. + cmd.cmdf = (int)(MSOLE.OLECMDF.OLECMDF_SUPPORTED | MSOLE.OLECMDF.OLECMDF_ENABLED); + prgCmds[0] = cmd; break; default: // Inform the shell that we don't support any other commands. @@ -486,13 +482,10 @@ 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; } - else - { - goto default; - } + // We enabled the command, so we say we handled it irrespective of the other conditions. + // See commands in QueryStatus regarding the enabled state of this command. + hr = VSConstants.S_OK; break; default: // If the command is from our command set, but not explicitly handled, inform the shell This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |