30
30
using MonoDevelop.Components.Commands;
31
using MonoDevelop.Ide;
32
using MonoDevelop.Ide.Gui;
32
34
namespace MonoDevelop.DesignerSupport
34
36
class PropertyPadVisitor: ICommandTargetVisitor
38
// Set to true when a property pad provider is found
41
// Set to true if the current active document has been visited
42
bool visitedCurrentDoc;
44
// Set to true if the current active document is being visited
46
bool visitingCurrentDoc;
48
Gtk.Widget activeWidget;
53
visitedCurrentDoc = false;
60
if (!visitingCurrentDoc && !visitedCurrentDoc) {
61
// A provider has not been found, but the current document has not been visited
62
// (the focus may be for example in a pad).
63
// Try visiting the command route again, but this time starting at the currently
64
// active document. The visitingCurrentDoc flag is used to avoid entering in a loop.
65
var wb = (DefaultWorkbench)IdeApp.Workbench.RootWindow;
66
if (wb.ActiveWorkbenchWindow != null) {
67
visitingCurrentDoc = true;
68
IdeApp.CommandService.VisitCommandTargets (this, wb.ActiveWorkbenchWindow);
69
visitingCurrentDoc = false;
70
// All done, VisitCommandTargets will set the final state of the pad
74
DesignerSupport.Service.ReSetPad ();
36
78
public bool Visit (object ob)
39
DesignerSupport.Service.ReSetPad ();
42
else if (ob is PropertyPad) {
80
if (activeWidget == null && ob is Gtk.Widget)
81
activeWidget = (Gtk.Widget) ob;
83
if (ob == ((DefaultWorkbench)IdeApp.Workbench.RootWindow).ActiveWorkbenchWindow)
84
visitedCurrentDoc = true;
86
if (ob is PropertyPad) {
43
87
// Don't change the property grid selection when the focus is inside the property grid itself
46
91
else if (ob is IPropertyPadProvider) {
47
DesignerSupport.Service.SetPadContent ((IPropertyPadProvider)ob);
92
DesignerSupport.Service.SetPadContent ((IPropertyPadProvider)ob, activeWidget);
50
96
else if (ob is ICustomPropertyPadProvider) {
51
DesignerSupport.Service.SetPadContent ((ICustomPropertyPadProvider)ob);
97
DesignerSupport.Service.SetPadContent ((ICustomPropertyPadProvider)ob, activeWidget);